Last active
July 29, 2020 12:28
-
-
Save section-io-gists/2eb0f267a08734f92003f06d295af22a to your computer and use it in GitHub Desktop.
Varnish 4.x to force HTTPS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub vcl_recv { | |
if (req.http.X-Forwarded-Proto !~ "https") { | |
return (synth(850, "Moved Permanently")); | |
} | |
} | |
sub vcl_synth { | |
if(resp.status == 850) { | |
set resp.http.Location = "https://" + req.http.host + req.url; | |
set resp.status = 301; | |
return(deliver); | |
} | |
} | |
sub vcl_hash { | |
hash_data(req.http.X-Forwarded-Proto); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment