Varnish cache in nginx reverse proxied WHM [closed]
Solution 1:
Based on the netstat
output, I can see that 2 listening ports were opened for varnishd
:
- port
8443
- port
6081
These are configured via -a
runtime parameters.
This setup is quite common, and usually refers to an HTTP listening port and a PROXY listening port.
Port 6081
Port 6081
is usually the HTTP port, even though it is configured using a non-standard port number.
In terms of runtime parameters it is usually configured as follows:
-a :6081
Or sometimes even as follows:
-a :6081,HTTP
In this case, Varnish will probably sit behind the Nginx proxy.
For standard HTTP, Nginx will need to proxy through to Varnish on port 6081
.
Port 8443
Port 8443
is usually configured for connections using the PROXY protocol.
The condition is that the node that sits in front of Varnish actually speaks PROXY.
In terms of runtime parameters, it will look like this:
-a :8443,PROXY
If I'm not mistaken, the open source version of Nginx doesn't support reverse proxying to another node using the PROXY protocol.
Using the right ports
Based on the netstat
output, Nginx listens on ports 443
and 80
, which is HTTPS and HTTP.
The httpd
service (which is Apache) runs on ports 444
for HTTPS and 81
for HTTP.
The goal is to route HTTP & HTTPS traffic from Nginx to Varnish and from Varnish to Apache.
This is the chain:
HTTPS -> NGINX (port 443) --> Varnish (port 6081) --> Apache (port 81)
^
|
HTTP -> NGINX (port 80) ----+
Magento configuration for Varnish
In your screenshot you used port 8443
as your backend port. This is not correct. Apache is listening on port 81
for HTTP traffic, this port should be your backend port.