Last active
April 23, 2019 12:42
-
-
Save jmara/2dc04073d4f1970ae6e20fe6a9b90eef to your computer and use it in GitHub Desktop.
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
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" | |
} -start | |
varnish v1 -vcl+backend { | |
import std; | |
sub vcl_backend_response { | |
if (beresp.status == 301 && beresp.http.location ~ "^http://") { | |
set bereq.http.host = regsuball(beresp.http.location, "^http://([^/]+)/.*", "\1"); | |
set bereq.url = regsuball(beresp.http.location, "^http://([^/]+)", ""); | |
set beresp.http.location = "https://" + bereq.http.host + bereq.url; | |
} | |
} | |
} -start | |
client c1 { | |
txreq -url "/foo" -hdr "host: foo.example.com" | |
rxresp | |
expect resp.status == 301 | |
expect resp.http.location ~ "^https://" | |
} -run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Redirect all http:// responses from backend to https:// in varnish