Created
April 26, 2021 13:36
-
-
Save aondio/9db41d8ce86e8b927601d87f5648ebfa to your computer and use it in GitHub Desktop.
Override host header
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 "host_header" | |
server s1 -repeat 2 { | |
rxreq | |
expect req.http.host == "overridden" | |
txresp | |
rxreq | |
expect req.http.host == "overridden" | |
txresp | |
} -start | |
varnish v1 -vcl { | |
import std; | |
import goto; | |
import directors; | |
backend default { | |
.host = "${bad_ip}"; | |
.port = "8089"; | |
} | |
sub vcl_init { | |
new rr = directors.fallback(); | |
new gd1 = goto.dns_director("${s1_addr}", "${s1_port}", host_header="overridden"); | |
rr.add_backend(gd1.backend()); | |
if (std.healthy(gd1.backend())) { } | |
} | |
sub vcl_recv { | |
# unset req.http.Host; | |
set req.backend_hint = rr.backend(); | |
# return (pass); | |
} | |
sub vcl_backend_fetch { | |
unset bereq.http.Host; | |
# set bereq.backend = rr.backend(); | |
} | |
} -start | |
client c1 { | |
txreq -hdr "Host: foo.com" | |
rxresp | |
expect resp.status == 200 | |
txreq -hdr "Host: bar.com" | |
rxresp | |
expect resp.status == 200 | |
} -run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment