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

  • Anyone? Please help me out. – Rahul Biswas Sep 5 '19 at 15:21

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;
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.