Created
March 17, 2017 13:30
-
-
Save gquintard/ee47432bb8b5c97b615d973b57b6338e to your computer and use it in GitHub Desktop.
Test XFF ip extraction
This file contains 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 "XFF test" | |
server s1 {} -start | |
varnish v1 -vcl+backend { | |
sub vcl_recv { | |
return (synth(200)); | |
} | |
sub vcl_synth { | |
set resp.http.x-cdn = regsub(req.http.xff, "([^,]+), *([^ ,]+)[ ,]?.*", "\2"); | |
} | |
} -start | |
client c1 { | |
txreq -hdr "xff: 1.1.1.1, 2.2.2.2, 3.3.3.3" | |
rxresp | |
expect resp.http.x-cdn == "2.2.2.2" | |
txreq -hdr "xff: 1.1.1.1,2.2.2.2 , 3.3.3.3 , 4.4.4.4" | |
rxresp | |
expect resp.http.x-cdn == "2.2.2.2" | |
} -run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment