I have installed varnish and nginx and secured my website with lets encrypt SSL. I tested varnish against nginx cgi cache and i have found out that varnish is a bit faster in my use case (wordpress). So i need some help on how to use nginx for SSL termination with varnish and how to forward http to https as my website is https only. I am running ubuntu 18.04
1 Answer
Add the below lines in /etc/varnish/default.vcl
sub vcl_recv { if ( (req.http.host ~ "^(?i)www.yourdomain.com" || req.http.host ~ "^(?i)www.yourdomain.com") && req.http.X-Forwarded-Proto !~ "(?i)https") { return (synth(750, "")); } } sub vcl_synth { if (resp.status == 750) { set resp.status = 301; set resp.http.Location = "https://www.yourdomain.com" + req.url; return(deliver); } }