I’ve got a working .vcl file (tested fine with Varnish on the default port 6081 and Nginx server as the backend on port 80)
But as soon as Nginx is moved away from port 80, WordPress just insists on a 301 redirect which actually serves up an empty response (not a blank page or the white screen of death).
It’s been a while, but the last time I set up Varnish, I placed it in front of nginx. So Varnish went on port 80, and nginx was on port 8080. If Varnish did not have a cached page, it would pass the request to nginx.
The first request is going to be what’s on port 80, since that is the port HTTP uses.
That’s exactly what I did. The problem is WordPress (via redirect_canonical I think) does a 301 redirect when it sees that the port doesn’t match.
port_in_redirect off; to nginx server block but it didn’t seem to help…
And the funny thing is I already strip off the port from HTTP
Host header in my .vcl file. Should I not be doing that? (Oh wait… This only matters if the request URL from browser contains a port number. Nevermind…)
Yes I do remember having
port_in_redirect off; in nginx.