[patch] include client_ip in X-Forwarded-For header
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Web Servers reviews > Perlbal > [patch] include client_ip in X-Forwarded-For header




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

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


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
03-29-07 12:11 AM

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/








[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 07:08 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register