0

We have our production server with latest cpanel version "96.0 (build 8)" and it is running nginx with reverse proxy enabled. See the netstat screenshot attached for detailed information. This server is currently in production and we are running two major websites one magento2 and other a wordpress. For improving prefomance of magento website we have started R&D on magento 2 staging area and enabled varnish cache.

enter image description here

Our plan was to implement magento2 with varnish cache and we have installed it and configured magento accordingly. Varnish default.vcl configuration is done as per magento2 standards. After implementing the scenario and testing varnish headers are not present. Has someone enable varnish in nginx reverse proxied cpanel server?

enter image description here

nisamudeen97
  • 111
  • 4

1 Answers1

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.

Thijs Feryn
  • 1,036
  • 3
  • 5
  • The concept is clear, the server is having Cpanel/WHM with nginx manager plugin installed. Unable to customize its port. – nisamudeen97 Jun 01 '21 at 13:28
  • I updated my answer, because I now notice that Apache is also in play here. I understand the limitations in terms of ports, but my updated answer takes these into account. – Thijs Feryn Jun 01 '21 at 14:18
  • Any Administrative panel Modified Servers are out of Scope on Serverfault, move your question to Superuser.com – djdomi Jun 01 '21 at 15:06
  • I am now setting up a plain server. with nginx and varnish in my test lab. I will keep my findings posed. – nisamudeen97 Jun 01 '21 at 17:13