File is here: https://github.com/magento/magento2/blob/2.2-develop/app/code/Magento/PageCache/etc/varnish5.vcl
As you can see, it has the pub hardcoded. I might suggest doing detection in the application, and adjusting the probe root accordingly.
I believe it's handled properly in other lines of the same file: if (req.url ~ "^/(pub/)?(media|static)/") {
Not sure why root index.php it still not removed in favor of pub/index.php though.
I'm not sure -- I don't know if Varnish caches it's own probes? To me that wouldn't make sense. Docs aren't helpful here:
https://varnish-cache.org/docs/4.0/reference/vcl.html#reference-vcl-probes
Additionally, tailing nginx logs seems to support this (with the pass directive disabled):
127.0.0.1 - - [01/Nov/2017:17:23:30 +0100] "GET /health_check.php HTTP/1.1" 200 5 "-" "-" "-"
127.0.0.1 - - [01/Nov/2017:17:23:35 +0100] "GET /health_check.php HTTP/1.1" 200 5 "-" "-" "-"
127.0.0.1 - - [01/Nov/2017:17:23:40 +0100] "GET /health_check.php HTTP/1.1" 200 5 "-" "-" "-"
127.0.0.1 - - [01/Nov/2017:17:23:45 +0100] "GET /health_check.php HTTP/1.1" 200 5 "-" "-" "-"
127.0.0.1 - - [01/Nov/2017:17:23:50 +0100] "GET /health_check.php HTTP/1.1" 200 5 "-" "-" "-"
127.0.0.1 - - [01/Nov/2017:17:23:55 +0100] "GET /health_check.php HTTP/1.1" 200 5 "-" "-" "-"
127.0.0.1 - - [01/Nov/2017:17:24:00 +0100] "GET /health_check.php HTTP/1.1" 200 5 "-" "-" "-"
127.0.0.1 - - [01/Nov/2017:17:24:05 +0100] "GET /health_check.php HTTP/1.1" 200 5 "-" "-" "-"
127.0.0.1 - - [01/Nov/2017:17:24:10 +0100] "GET /health_check.php HTTP/1.1" 200 5 "-" "-" "-"
127.0.0.1 - - [01/Nov/2017:17:24:15 +0100] "GET /health_check.php HTTP/1.1" 200 5 "-" "-" "-"
127.0.0.1 - - [01/Nov/2017:17:24:20 +0100] "GET /health_check.php HTTP/1.1" 200 5 "-" "-" "-"
127.0.0.1 - - [01/Nov/2017:17:24:25 +0100] "GET /health_check.php HTTP/1.1" 200 5 "-" "-" "-"
Oh also I patched this to remove the pub. Specifically, we route based on virtualhosts rather than ports:
backend default {
.host = "127.0.0.1";
.port = "80";
.first_byte_timeout = 600s;
.probe = {
# SITEWARDS CHANGES START
# The normal probe configuration does not allow setting specific headers for request[1]. So, the below snippet
# manually constructors the request to include the Host header.
#
# [1] https://varnish-cache.org/lists/pipermail/varnish-misc/2011-October/021298.html
.request =
"GET /health_check.php HTTP/1.1"
"Host: magento.local"
"Connection: close";
# SITEWARDS CHANGES END
.timeout = 2s;
.interval = 5s;
.window = 10;
.threshold = 5;
}
}
Hi @andrewhowdencom
Could you please let us know if the issue is still actual? Thank you
Looks like it. As mentioned, i customised the VCL in production for us as above, for various reasons. But the 2.2 develop branch still has the path hard-coded.
I imagine the rule "if you need two versions of index.php you'll probably need two versions of health_check.php" holds true.
https://github.com/magento/magento2/blob/2.2-develop/app/code/Magento/PageCache/etc/varnish5.vcl#L13
@andrewhowdencom, thank you for your report.
We've created internal ticket(s) MAGETWO-83718 to track progress on the issue.
This is still an issue.
pub 鈥斅爐he proper way to run PHP apps)pub in them for whatever reasonSpecifically the following lines:
Line 12: .url = "/pub/health_check.php"; (why is /pub there? of course backend origin is going to 404, making Varnish think that the node is down..)
Line 65:
# Bypass health check requests
if (req.url ~ "/pub/health_check.php") {
return (pass);
}
How is this still open after multiple years? Or maybe we're all expected to investigate the exported VCL file and catch the error ourselves?
Hi @engcom-Alfa. Thank you for working on this issue.
Looks like this issue is already verified and confirmed. But if you want to validate it one more time, please, go though the following instruction:
Component: XXXXX label(s) to the ticket, indicating the components it may be related to.[ ] 2. Verify that the issue is reproducible on 2.4-develop branchDetails
- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
- If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
- If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and _stop verification process here_!
[ ] 3. If the issue is not relevant or is not reproducible any more, feel free to close it.
:white_check_mark: Confirmed by @engcom-Alfa
Thank you for verifying the issue. Based on the provided information internal tickets MC-30080 were created
Issue Available: @engcom-Alfa, _You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself._
Hi @engcom-Alfa. Thank you for working on this issue.
Looks like this issue is already verified and confirmed. But if you want to validate it one more time, please, go though the following instruction:
Component: XXXXX label(s) to the ticket, indicating the components it may be related to.2.4-develop branch@magento give me 2.4-develop instance to deploy test instance on Magento infrastructure. 2.4-develop branch, please, add the label Reproduced on 2.4.x.Hi @andrewhowdencom .
According to the Magento documentation in part Advanced Varnish configuration described that:
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.
If you manually change the path to .url = "/health_check.php"; everything work correctly.
Manual testing scenario:
/pub/health_check.php to health_check.php and Save;Actual Result: :heavy_check_mark: Server works

@andrewhowdencom Could you take a look?
Thanks!
@andrewhowdencom , I am closing this issue now due to inactivity.
Please reopen and update if you wish to continue.
Thank you for the collaboration!
I think the desired result on this one would be to detect what mode the store is running in (given that it itself can introspect and determine what the suitable varnish configuration would be), and export things appropriately without requiring developer input.
Most helpful comment
How is this still open after multiple years? Or maybe we're all expected to investigate the exported VCL file and catch the error ourselves?