Skip to content

Instantly share code, notes, and snippets.

@wpottier
Created August 1, 2016 14:10
Show Gist options
  • Save wpottier/7dca182baa8bd3d2d4bd8b4ef0278a36 to your computer and use it in GitHub Desktop.
Save wpottier/7dca182baa8bd3d2d4bd8b4ef0278a36 to your computer and use it in GitHub Desktop.
sample.vcl
sub vcl_recv {
if (client.ip != "127.0.0.1" && std.port(server.ip) == 80 && req.http.host ~ "^(?i)example.com") {
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);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment