Varnish

From Tafoya.co
Jump to navigation Jump to search

Redirect to HTTPS

sub vcl_recv {
       if ( (req.http.host ~ "^(?i)www.domain.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.domain.com" + req.url;
       return(deliver);
   }
}