1

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://github.com/magento/magento2/commit/882379061809b806fc5580729a6c9c78d782f84d#diff-2f64f6171deecba61bea147539cf72ec

https://devdocs.magento.com/guides/v2.3/config-guide/varnish/config-varnish-advanced.html

2 Answers 2

2

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 to health_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

Edit

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.

2
  • But are we supposed to remove other references as well? line 67,102,206 of VCL also refer to pub directory
    – Zoya
    Commented Feb 13, 2020 at 4:34
  • Lines 102,206 are regex that is setup to work with and without pub. And line 62, yeah that needs to be updated aswell if you want to use the health checks. github.com/magento/magento2/pull/25360/…
    – Sam
    Commented Feb 13, 2020 at 8:54
1

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.

2
  • You didn't get my question. Magento documentation says remove 'pub' from line 13 if the Magento root directory is pub? So my question is why is they have not informed customers to remove other pub references as well.
    – Zoya
    Commented Feb 12, 2020 at 18:09
  • if your Magento root is pub, then you should remove it from line 102 just not to cache the request, in line 13 you must remove to avoid 404 not found. in line 102 pub is optional in this regex so it's no problem to leave it.
    – Ahmed Atef
    Commented Feb 12, 2020 at 18:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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