Perlbal - [patch] include client_ip in X-Forwarded-For header

This is Interesting: Free IT Magazines  
Home > Archive > Perlbal > March 2007 > [patch] include client_ip in X-Forwarded-For header





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author [patch] include client_ip in X-Forwarded-For header
Ask Bjørn Hansen

2007-03-28, 7:11 pm

Currently the X-Forwarded-For header is only reset when the upstream
is *not* trusted.

The patch below changes it so the client ip is added to the X-
Forwarded-For header when the upstream *is* trusted.

(I noticed this was missing when I upgraded to 1.55 from CPAN rather
than from my working copy :-) )


- ask


Index: lib/Perlbal/BackendHTTP.pm
========================================
===========================
--- lib/Perlbal/BackendHTTP.pm (revision 643)
+++ lib/Perlbal/BackendHTTP.pm (working copy)
@@ -215,6 +215,10 @@
$hds->header("X-Host", undef);
$hds->header("X-Forwarded-Host", undef);
}
+ else {
+ my @ips = split /,\s*/, ($hds->header("X-Forwarded-For") ||
'');
+ $hds->header("X-Forwarded-For", join ", ", @ips, $client_ip);
+ }
$self->tcp_cork(1);
$client->state('backend_req_sent');
Index: CHANGES
========================================
===========================
--- CHANGES (revision 643)
+++ CHANGES (working copy)
@@ -1,3 +1,7 @@
+
+ -- Add the client_ip to the X-Forwarded-For header when the
+ upstream is "trusted" (Ask Bjoern Hansen).
+
1.55: 2007-03-21
-- add plugin that returns 304 automatically on incoming requests


--
http://develooper.com/ - http://askask.com/



Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com