Hi,
I've set up M2 (2.0.4 CE) and Varnish.
Varnish seems to be working ok.
The problem I have is trying to set up Magento to purge the Varnish cache when I flush the magento cache.
I've set it up 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
But when I hit Flush Magento Cache in admin, whilst running varnishlog, the log file says (amongst other things) - I've replaced my domain with {my domain}
* << 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 backend, but it's throwing a 403 error.
Any ideas please?
Thanks
Solved! Go to Solution.
Ok, I've found a workaround to this problem on another forum.
See the post by davidalger at https://www.bountysource.com/issues/29113272-no-varnish-purge-request-from-nginx
This fixes it. Basically the server path isn't being set properly and this code fixes it.
That solves the main problem of the varnish cache not clearing from the Magento 2 admin, but I'm still unsure why /app/etc/config.php is being requested after that.
Thanks
Just to add, 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.
Sorry, before that log it also says
* << Request >> 2 - Begin req 1 rxreq - Timestamp Start: 1459708682.774223 0.000000 0.000000 - Timestamp Req: 1459708682.774223 0.000000 0.000000 - HttpGarbage "PURGE%00" - ReqAcct 47 0 47 28 0 28 - End * << Session >> 1 - Begin sess 0 HTTP/1 - SessOpen 127.0.0.1 54199 :80 127.0.0.1 80 1459708682.774100 18 - Link req 2 rxreq - SessClose RX_JUNK 0.000 - End
Any ideas?
Ok, I've found a workaround to this problem on another forum.
See the post by davidalger at https://www.bountysource.com/issues/29113272-no-varnish-purge-request-from-nginx
This fixes it. Basically the server path isn't being set properly and this code fixes it.
That solves the main problem of the varnish cache not clearing from the Magento 2 admin, but I'm still unsure why /app/etc/config.php is being requested after that.
Thanks