In varnish configuration file I put my public address inside acl. Still I can not purge varnish cache. It shows 403 error. I want to purge varnish remotely.I want to purge varnish only from my IP. Please help me how I can set the acl.

  • What is your complete VCL file? Do you use SSL termination (via Nginx)? – Danila Vershinin Oct 3 '16 at 11:00
  • I am not using ssl. I am using cloudflare. Is varnish getting the IP of cloudflare ? – linux404 Oct 3 '16 at 13:07
  • Yep. That explains it. You will need to update purge logic to check for X-Forwarded-For header value to match your IP address. – Danila Vershinin Oct 3 '16 at 14:30
  • How can I do it ? – linux404 Oct 3 '16 at 15:46
  • Check my answer. Tested with Varnish 4. – Danila Vershinin Oct 3 '16 at 21:08

You can look at this tutorial purging varnish cache remotely

 sub vcl_recv {
     if (req.method == "PURGE") {
         # If not allowed then a error 405 is returned
         if (! req.http.x-forwarded-for || req.http.x-forwarded-for !~ "") {
            return(synth(405, "This forwarded IP is not allowed to send PURGE requests."));
        return (purge);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.