Skip to content

Instantly share code, notes, and snippets.

@gquintard
Created December 18, 2016 15:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gquintard/3a708c59f2232f9a959b3d374762a1e4 to your computer and use it in GitHub Desktop.
Save gquintard/3a708c59f2232f9a959b3d374762a1e4 to your computer and use it in GitHub Desktop.
varnishtest "30X redirections"
server s1 {}
varnish v1 -vcl+backend {
sub vcl_recv {
if (req.http.host != "www.varnish-software.com") {
set req.http.location = "https://www.varnish-software.com/";
return(synth(301));
}
}
sub vcl_synth {
if (resp.status == 301 || resp.status == 302) {
set resp.http.location = req.http.location;
return (deliver);
}
}
} -start
client c1 {
txreq -hdr "host: varnish"
rxresp
expect resp.status == 301
expect resp.http.location == "https://www.varnish-software.com/"
expect resp.reason == "Moved Permanently"
} -run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment