Question

I am using Varnish 3 in front of nginx running multiple WordPress sites. I am using a default.vcl recommended and used by many large WordPress sites.

default.vcl: http://pastebin.com/KaSdvuRS

I am using W3 Total Cache which has an option to automatically purge when clearing the cache. I also tested installing Varnish HTTP Purge plugin to purge posts/pages when editing them. Neither seemed to work so I tested interactive session over ssh w/ curl.

I am logged into SSH on the varnish/nginx box, and I type the following command to test the varnish purge:

curl -X PURGE http://www.example.com

The result is:

<head>
    <title>405 Not allowed.</title>
  </head>
  <body>
    <h1>Error 405 Not allowed.</h1>
    <p>Not allowed.</p>
    <h3>Guru Meditation:</h3>
    <p>XID: 265824636</p>
    <hr>
    <p>Varnish cache server</p>
  </body>

Any ideas what I am missing? This vcl file is very similar to what is recommended by Varnish-Cache.org for WordPress and is the purge configuration I see recommended everywhere.

Was it helpful?

Solution

Chances are, you're connecting to your Varnish box via the public IP and Varnish will also see a public IP connecting, not a local one. Your ACL for purges now only allows localhost/127.0.0.1. You may want to extend that list with the public IP address of your server as well.

Alternatively, try debugging by removing the ACL check and by simply allowing purges from everyone, just to exclude the ACL as the guilty one.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top