Created
February 22, 2016 14:11
-
-
Save ssm/51b4fc7151207a0afbd1 to your computer and use it in GitHub Desktop.
This file contains 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 redirect_to_https { | |
if (std.port(local.ip) == 80) { | |
set req.http.x-redir = "https://" + req.http.host + req.url; | |
return(synth(850, "Moved permanently")); | |
} | |
} | |
sub vcl_synth { | |
if (resp.status == 850) { | |
set resp.http.Location = req.http.x-redir; | |
set resp.status = 302; | |
return (deliver); | |
} | |
} | |
sub vcl_recv { | |
if ( req.http.host == "example.com" || req.http.host == "www.example.com" ) { | |
call redirect_to_https; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment