Are we supposed to remove reference of pub from line 67,102,206 of VCL like we remove from line 13 if the Magento root directory is pub?
https://devdocs.magento.com/guides/v2.3/config-guide/varnish/config-varnish-advanced.html
Are we supposed to remove reference of pub from line 67,102,206 of VCL like we remove from line 13 if the Magento root directory is pub?
https://devdocs.magento.com/guides/v2.3/config-guide/varnish/config-varnish-advanced.html
Correct, you have the following hidden in the varnish config guide on the Devdocs https://devdocs.magento.com/guides/v2.3/config-guide/varnish/config-varnish-advanced.html#health
The health_check.php script is located in the pub directory. If your Magento root directory is pub, then be sure to change the path in the url parameter from
/pub/health_check.php
tohealth_check.php
.
On a side note there is a active pull request currently in testing for this issue aswell
https://github.com/magento/magento2/pull/25360
A bit of further clarification, lines 102 + 206 are setup to work both from pub and from the app root. The ^(pub/)?
part of the url match means 0 or more instances of pub/
at the start.
And if you want to run the health checks you need to update line 67 also to remove pub from that url match otherwise it wil cache the health check responses.
Line 67
if (req.url ~ "/pub/health_check.php") {
return (pass);
}
tells varnish not to cache this file health_check.php
because it used to check your website status, varnish will request it every 5 seconds, if it gives 200 then your website is ok, if not - depending on your varnish configuration - you will get varnish 503 backend fetch error
.
same as in lines 102, 206. If you are not going to use cdn and want varnish to cache your media and static files comment line 104 and uncomment 207,208,209. if you are on cdn, leave it as is.
pub
is optional in this regex so it's no problem to leave it.
Commented
Feb 12, 2020 at 18:16