I have a Magento 2.4.8 site running on Nginx + Varnish (version 7.5.0).
When I test caching via curl, I get different results for HTTP vs HTTPS:
curl -I http://domain/
- shows: X-Magento-Cache-Debug: HIT/MISS
But when I test caching via HTTPS curl :
curl -I https://domain/
- does NOT show any Varnish headers (no HIT/MISS, no Via header)
So it looks like Varnish is being bypassed completely for HTTPS traffic.
My site URL in Magento configuration is set to use https://domain/.
My Setup
-
Nginx is used as the web server.
-
Varnish is listening on port 80.
-
Backend Nginx for Magento is on port 8080.
Varnish service File (/lib/systemd/system/varnish.service) code:
ExecStart=/usr/sbin/varnishd
-j unix,user=vcache
-a :80
-T localhost:6082
-f /etc/varnish/default.vcl
-S /etc/varnish/secret
-s malloc,512m
Backend block in /etc/varnish/default.vcl:
backend default {
.host = "127.0.0.1";
.port = "8080";}
Nginx SSL block (/etc/nginx/sites-enabled/default.conf):
server {
listen 8080 default_server;
listen [::]:8080 default_server;
listen 443 ssl;
server_name <server_name>;
set $MAGE_ROOT /var/www/html/magento;
set $MAGE_MODE production;
set $MAGE_RUN_TYPE store;
set $MAGE_RUN_CODE default;
include /var/www/html/magento/nginx.conf.sample;
}
How can I configure Nginx and Varnish so that HTTPS requests are correctly passed through Varnish?
Any ideas Please share.
Thank you!