Varnish not purging via Magento 2 - throwing 403 Forbidden error - help please

John Risby john at alcoholfree.co.uk
Sat Apr 2 21:19:13 CEST 2016


Hi all,

I've set up Magento 2 (2.0.4 CE) and Varnish .

Varnish seems to be working ok - pages are being cached and served from the
cache (first page load takes a few seconds, next load takes 100 or so ms).

The problem I have is trying to set up Magento to purge the Varnish cache
when I flush the magento cache in the magento backend.

I've set it up as described in the official magento docs using

bin/magento setup:config:set --http-cache-hosts=127.0.0.1

My /etc/varnish/default.cfg file has the purge acl set to 127.0.0.1 (I've
also tried the external IP and localhost too).

But when I hit Flush Magento Cache in admin, whilst running varnishlog, the
log file says (amongst other things) - note, I've replaced my domain with
{MY_DOMAIN} and my server IP with {SERVER_IP}

*   << BeReq    >> 32924
-   Begin          bereq 32923 pass
-   Timestamp      Start: 1459552787.509708 0.000000 0.000000
-   BereqMethod    POST
-   BereqURL       /app/etc/config.php
-   BereqProtocol  HTTP/1.1
-   BereqHeader    Host: {MY_DOMAIN}
-   BereqHeader    Accept: */*
-   BereqHeader    Content-Length: 0
-   BereqHeader    Content-Type: application/x-www-form-urlencoded
-   BereqHeader    X-Forwarded-For: {SERVER_IP}
-   BereqHeader    X-Varnish: 32924
-   VCL_call       BACKEND_FETCH
-   VCL_return     fetch
-   BackendOpen    23 boot.default 127.0.0.1 8080 127.0.0.1 53519
-   Timestamp      Bereq: 1459552787.509933 0.000225 0.000225
-   Timestamp      Beresp: 1459552787.511332 0.001625 0.001399
-   BerespProtocol HTTP/1.1
-   BerespStatus   403
-   BerespReason   Forbidden
-   BerespHeader   Date: Fri, 01 Apr 2016 23:19:47 GMT
-   BerespHeader   Server: Apache/2.4.7 (Ubuntu)
-   BerespHeader   Content-Length: 299
-   BerespHeader   Content-Type: text/html; charset=iso-8859-1
-   TTL            RFC -1 10 -1 1459552788 1459552788 1459552787 0 0
-   VCL_call       BACKEND_RESPONSE
-   TTL            VCL 0 10 0 1459552788
-   VCL_return     deliver
-   BerespUnset    Content-Length: 299
-   BerespHeader   Content-Encoding: gzip
-   BerespHeader   Vary: Accept-Encoding
-   Storage        malloc Transient
-   ObjProtocol    HTTP/1.1
-   ObjStatus      403
-   ObjReason      Forbidden
-   ObjHeader      Date: Fri, 01 Apr 2016 23:19:47 GMT
-   ObjHeader      Server: Apache/2.4.7 (Ubuntu)
-   ObjHeader      Content-Type: text/html; charset=iso-8859-1
-   ObjHeader      Content-Encoding: gzip
-   ObjHeader      Vary: Accept-Encoding
-   Fetch_Body     3 length -
-   Gzip           G F E 299 259 80 1992 2002
-   BackendReuse   23 boot.default
-   Timestamp      BerespBody: 1459552787.511812 0.002104 0.000479
-   Length         259
-   BereqAcct      191 0 191 160 0 160
-   End

So Varnish is correctly being asked to purge via the magento backend, but
it's throwing a 403 error.

It works via telnet both via 127.0.0.1 and the real IP of the server

telnet 127.0.0.1 80
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
PURGE / HTTP/1.1
X-Magento-Tags-Pattern: .*

HTTP/1.1 200 Purged
Date: Fri, 01 Apr 2016 23:39:08 GMT
Server: Varnish
X-Varnish: 229397
Content-Type: text/html; charset=utf-8
Retry-After: 5
Content-Length: 241
Accept-Ranges: bytes
Connection: keep-alive

<!DOCTYPE html>
<html>
  <head>
    <title>200 Purged</title>
  </head>
  <body>
    <h1>Error 200 Purged</h1>
    <p>Purged</p>
    <h3>Guru Meditation:</h3>
    <p>XID: 229397</p>
    <hr>
    <p>Varnish cache server</p>
  </body>
</html>

Connection closed by foreign host.

Any ideas please?

Thanks
John
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20160402/224e239b/attachment.html>


More information about the varnish-misc mailing list