On Fri May 05 09:18:12 2006, BOOK wrote:
Show quoted text> For the outgoing connection (from proxy to origin server), this is
> handled by LWP::UserAgent. I do not think that LWP::UserAgent lets
> one decide which interface is used.
>
> So, unless there is a way I don't know to enforce this in
> LWP::UserAgent, I'm afraid there is no way to support such
> a parameter.
Hello!
I had exactly this issue, because I was setting up multiple HTTP::Proxy
processes to listen on each of 5 IP addresses. Then I wanted each of
the 5 to go out its own IP address... e.g.:
./proxy.pl host 10.0.0.1 &
./proxy.pl host 10.0.0.2 &
./proxy.pl host 10.0.0.3 &
But, outoging connections always came out through 10.0.0.1 (the primary
netowrk interface).
I was easily able to solve it by modifying HTTP/Proxy.pm and adding:
local-address => $self->host
to sub _init_agent, like so:
sub _init_agent {
my $self = shift;
my $agent = LWP::UserAgent->new(
env_proxy => 1,
keep_alive => 2,
parse_head => 0,
#add local_address so the proxy goes out the IP that is bound to, and
not just the default
local_address => $self->host,
timeout => $self->timeout,
)
or die "Cannot initialize proxy agent: $!";
$self->agent($agent);
return $agent;
}
Hopefully that helps!