perl-modperl-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kh...@hyperreal.org
Subject cvs commit: modperl mod_perl_tuning.pod
Date Mon, 22 Mar 1999 19:43:09 GMT
khera       99/03/22 11:43:06

  Modified:    .        mod_perl_tuning.pod
  Log:
  Use a slightly optimized snippet of code for the X-Forwarded-For
  header processing example.  Idea from Andreas J. Koenig.  Benchmark
  shows this method to be just ever so slightly faster than doing a
  split/pop like we were before.  But since every cycle counts, we use it!
  
  Revision  Changes    Path
  1.12      +8 -5      modperl/mod_perl_tuning.pod
  
  Index: mod_perl_tuning.pod
  ===================================================================
  RCS file: /home/cvs/modperl/mod_perl_tuning.pod,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- mod_perl_tuning.pod	1999/03/01 08:58:29	1.11
  +++ mod_perl_tuning.pod	1999/03/22 19:43:03	1.12
  @@ -360,8 +360,7 @@
    sub My::SquidRemoteAddr ($) {
      my $r = shift;
    
  -   my @ip = split(/,\s*/, $r->header_in('X-Forwarded-For'));
  -   if (my $ip = pop(@ip)) {
  +   if (my ($ip) = $r->header_in('X-Forwarded-For') =~ /([^,\s]+)$/) {
        $r->connection->remote_ip($ip);
      }
    
  @@ -374,7 +373,11 @@
   
   This will cause every request to have its C<remote_ip> address
   overridden by the value set in the C<X-Forwarded-For> header added by
  -Squid.
  +Squid.  Note that if you have multiple proxies between the client and
  +the server, you want the IP address of the last machine before your
  +accelerator.  This will be the right-most address in the
  +X-Forwarded-For header (assuming the other proxies append their
  +addresses to this same header, like Squid does.)
   
   If you use apache with mod_proxy at your frontend, you can use Ask
   Bjørn Hansen's mod_proxy_add_forward module from
  @@ -416,5 +419,5 @@
   check the web pages http://perl.apache.org/ and http://www.apache.org/
   for explanations of the configuration options.
   
  -$Revision: 1.11 $
  -$Date: 1999/03/01 08:58:29 $
  +$Revision: 1.12 $
  +$Date: 1999/03/22 19:43:03 $
  
  
  

Mime
View raw message