I'm testing an application that runs behind a lightweight Apache as a proxy, and I need to give it different IPs as part of the testing regimen to exercise the Geotargetting part of the application. So to live test the application, I wrote live test harness where I can put different parameters like the referrer url, the remote ip, etc into form widgets, and puts that all into the location of an IFRAME when I submit the form.
Then I used HTTP::Proxy and HTTP::Proxy::HeaderFilter to strip the referer URL and IP address from the query string, and to attach them to the request object as the 'Referer' and 'X-Forwarded-For' headers instead:
Unfortunately, the IP address ends up at the beginning of the 'X-forwarded-For' header, and not the end:package EngineTestFilter; use base qw/HTTP::Proxy::HeaderFilter/; use strict; use warnings; sub filter { my ($self, $headers, $request) = @_; my $uri = $request->uri(); my ($location, $query) = split(/\?/, $uri); my %params = map { split /=/ } map { split /&/ } $query; $request->uri($location .'?'.join('&', map { "$_=$params{$_}" } qw/ +a s/)); $headers->header(Referer => $params{referer}); $headers->remove_header('X-Forwarded-For'); $headers->header('X-Forwarded-For' => $params{remote_ip}); }
I hunted up though the chain of inheritance all the way up to HTTP::Message, and I could not find where the 'X-Forwarded-For' header gets handled in all of that.'X-Forwarded-For' => '207.177.71.108, 10.0.0.50, 10.0.0.50',
Anyone got a cluestick for me?
In reply to HTTP::Proxy and X-Forwarded-For headers by cleverett
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |