I am trying to use Varnish and Nginx in a WP site using HTTPS.
Everything is working fine with cached files but when Varnish discover something it shouldn't cache, it sends it back to Nginx. At this point, Nginx is sending the HTTPS request to Varnish again causing the infinite loop.
I have tried a lot of things and searched over the Internet a lot but nothing has worked so far.
This is an example of something Varnish is sending back:
if (req.url ~ "/wp-(login|admin|cron)") {
# Don't cache, pass to backend
return (pass);
}
And this is the Nginx location block which deals with 433:
location / {
# Send request to varnish
proxy_pass http://127.0.0.1:8888;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Port 443;
proxy_set_header Host $host;
}
I guess that Varnish is sending with the return(pass)
the data back to Nginx, but I don't now how to render that data using another location block.
How can I catch in Nginx the request which is coming from Varnish and distinguish between that and the requests which are coming from the regular 433 port?
Thanks in advance!