Skip to content

Instantly share code, notes, and snippets.

@gquintard gquintard/301-2.vtc
Created Dec 18, 2016

Embed
What would you like to do?
varnishtest "Long vcl/backend names"
server s1 {
rxreq
txresp -status 301 -hdr "Location: http://bar.example.com/bar"
expect req.http.host == "foo.example.com"
expect req.url == "/foo"
rxreq
txresp -status 301 -hdr "Location: http://baz.example.com/baz"
expect req.http.host == "bar.example.com"
expect req.url == "/bar"
rxreq
txresp -hdr "final: true"
expect req.http.host == "baz.example.com"
expect req.url == "/baz"
} -start
varnish v1 -vcl+backend {
import std;
sub vcl_backend_response {
if (beresp.status == 301 && beresp.http.location ~ "^https?://[^/]+/") {
set bereq.http.host = regsuball(beresp.http.location, "^https?://([^/]+)/.*", "\1");
set bereq.url = regsuball(beresp.http.location, "^https?://([^/]+)", "");
return (retry);
}
}
} -start
client c1 {
txreq -url "/foo" -hdr "host: foo.example.com"
rxresp
expect resp.status == 200
expect resp.http.final == "true"
} -run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.