Perlbal, Squid & X-Forwarded-For

Kate Turner kate.turner at gmail.com
Thu Jan 13 10:36:20 PST 2005


On Thu, 13 Jan 2005 18:25:06 +0000, Mike Whitaker <mike at altrion.org> wrote:
> >> Would it be different to implement support for appending Perlbal's
> >> client's IP to the X-F-F, and forwarding the entire thing?  E.g. if
> >> 1.2.3.4 is the client, and 10.0.0.1 is the squid, perlbal would
> >> forward:
> >>
> >> X-Forwarded-For: 1.2.3.4, 10.0.0.1
> 
> IIRC, this is not the correct way - you should, unless my memory's at
> fault, have multiple X-Forwarded-For's in this case, most recent...
> erm, first I think :)

Hmm.  I thought I remembered Squid doing it this way.

The code says:

        $hopips = array_map( 'trim', explode( ',',
$_SERVER['HTTP_X_FORWARDED_FOR'] ) );

        $allsquid = array_merge($wgSquidServers, $wgSquidServersNoPurge);
        while(in_array(trim(end($hopips)), $allsquid)){
                array_pop($hopips);
        }
        $wgIP = trim(end($hopips));

Maybe PHP changes it into the comma-separated list.  Hm.  But whatever
it does, it seems to work... :-)

Kate.


More information about the perlbal mailing list