This write up explains how to use NGiNX and Varnish in conjunction with multi-node npm Enterprise configurations. The goal is to use Varnish to provide load balancing and caching and use NGiNX as a SSL terminating reverse proxy.
The recommended topology is to provide a dedicated host for NGiNX and Varnish to run on. In environments where a secondary instance is warranted to support load, running NGiNX and Varnish on the primary will only introduce competition for resources and could destabilize your environment.
IMPORTANT The configuration files provided assume that NGiNX and Varnish are each running on the same dedicated host, separate from the hosts for the primary and secondary npmE instances.
Install Varnish and NGiNX using your distro's package manager. Varnish runs on port 6081 by default. The configuration provided will cause NGiNX to listen on ports 80, 443, and 4443.
sudo nano /etc/nginx/nginx.conf
- edit the
nginx.conf
file provided according to the steps listed at the top - edit
/etc/sysctl.conf
and change or add the linefs.file-max = 4096
- copy your SSL pem file to
/etc/nginx/wildcard.pem
- reload the NGiNX configuration with
sudo nginx -s reload
- edit the
sudo nano /etc/varnish/default.vcl
- edit the
varnish.vcl
file provided according to the steps listed at the top - restart varnish:
- on Debian sytems -
sudo service varnish restart
- on CentOS/RHEL systems -
sudo systemctl restart varnish
- on Debian sytems -
- edit the