[4.0] 3e8874e Collapse multiple X-Forwarded-For headers
Lasse Karstensen
lkarsten at varnish-software.com
Thu Jan 15 16:35:43 CET 2015
commit 3e8874ed945de580a92819b01c457b2734c6888b
Author: Federico G. Schwindt <fgsch at lodoss.net>
Date: Wed Jan 14 04:32:50 2015 +0000
Collapse multiple X-Forwarded-For headers
Fixes #1650
diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index cc5ede9..88eaa53 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -724,6 +724,7 @@ cnt_recv(struct worker *wrk, struct req *req)
* This really should be done earlier, but we want to capture
* it in the VSL log.
*/
+ http_CollectHdr(req->http, H_X_Forwarded_For);
if (http_GetHdr(req->http, H_X_Forwarded_For, &xff)) {
http_Unset(req->http, H_X_Forwarded_For);
http_PrintfHeader(req->http, "X-Forwarded-For: %s, %s",
diff --git a/bin/varnishtest/tests/r01650.vtc b/bin/varnishtest/tests/r01650.vtc
new file mode 100644
index 0000000..e21ceba
--- /dev/null
+++ b/bin/varnishtest/tests/r01650.vtc
@@ -0,0 +1,16 @@
+varnishtest "xff handling discards multiple headers"
+
+server s1 {
+ rxreq
+ expect req.http.X-Forwarded-For == "1.2.3.4, 5.6.7.8, 127.0.0.1"
+ txresp
+} -start
+
+varnish v1 -vcl+backend {
+} -start
+
+client c1 {
+ txreq -hdr "X-Forwarded-For: 1.2.3.4" -hdr "X-Forwarded-For: 5.6.7.8"
+ rxresp
+} -run
+
More information about the varnish-commit
mailing list