Last active
April 21, 2019 16:11
-
-
Save section-io-gists/07540ad2f3339eba4a4dbce5939c1d26 to your computer and use it in GitHub Desktop.
Force traffic to HTTPS in Varnish 3.x
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") { | |
error 850 "Moved permenantly"; | |
} | |
} | |
sub vcl_error { | |
if(obj.status == 850) { | |
set obj.http.Location = "https://" + req.http.host + req.url; | |
set obj.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