0

I am thinking to install varnish cache on a small VPS configuration. My VPS configuration is 2 core CPU & 2 GB RAM with 50 GB SSD.

I would like to know on such small VPS configuration what should be best to install

  1. Varnish Cache, Nginx Web server (PHP & MySQL also)
  2. Nginx Cache (for static file caching) on top of Nginx webserver along with PHP & MySQL

Fyi I also need to install SSL on all virtual host. What I know by default Varnish doesn't work on SSL. There should be additional things has to be installed to support SSL. So if I have to install multiple service on server to support varnish cache does it not better to use the nginx only with nginx cache remembering the server specs are low.

I am waiting for an open discussion to find best solution. Thanks in advance.

Sanjay Goswami
  • 822
  • 1
  • 16
  • 36
  • If your production Queries per Second are less than 5 after your busiest hour of uptime, keep your life simple and only install required MySQL, PHP and SSL support. – Wilson Hauck Jan 09 '23 at 16:52

1 Answers1

2

Nginx is a great webserver, but isn't a specialized reverse caching proxy. Varnish is specifically built for caching and its caching policies are far more granular.

Components

  • Use Hitch as your TLS proxy
  • Use Varnish for caching
  • Use Nginx as your webserver and connect to Nginx from Varnish

See https://www.varnish-software.com/developers/tutorials/terminate-tls-varnish-hitch/ for a tutorial on how to install Hitch for TLS termination.

See https://www.varnish-software.com/developers/tutorials/#installations for a list of tutorials (per platform and distribution) on how to install Varnish.

Port configuration

  • Configure Nginx to listen on port 8080
  • Configure Varnish to listen on port 80
  • Add an additional listening interface in Varnish on port 8443 for PROXY protocol traffic
  • Configure Hitch to listen on port 443
  • Let Hitch connect to Varnish over port 8443 via the PROXY protocol
  • Let Varnish connect to Nginx over port 8080 via a backend definition
Thijs Feryn
  • 3,982
  • 1
  • 5
  • 10