On Sun, Nov 12, 2000 at 11:07:59AM +0800, Alson Wong wrote:
>
> So, how do I pass/set the environment variable of REMOTE_ADDR from
> server A ? So that I can control the env of remote_addr at the server
> B ?
Well, you could do it several ways. The "normal" way is to set a
header in the request that A sends to be, usually the same one that
various caching proxy servers do, namely X-Forwarded-For. You won't
be able to do that with LWP::Simple, have a look at the main LWP
page for details on how to make more sophisticated requests. I'm
assuming you've ruled out using Apache's mod_proxy, and therefore that
you won't be wanting to use mod_proxy_add_forward.
Then, in the B server, you can peel it out of the Apache request
object manually as part of your script, or you can do it in an earlier
handler phase and make a $r->remote_ip() call like the one you were
making in the A server.
To catch the header on the backend, you can have a look at the
Guide:
http://thingy.kcilink.com/modperlguide/scenario/Getting_the_Remote_Server_IP_in_.html
> my $r = shift;
> $r->connection->remote_ip('1.2.3.4');
>
> it only works in server A, meaning,
> $ENV{'REMOTE_ADDR'} in Server A return 1.2.3.4, but $ENV
> {'REMOTE_ADDR'} in server B still return the Server A ip address.
Right: nothing passes environment variables between the servers. You
need to establish your own channel (the header mentioned above) for
passing that value and tweak the B server to recover the value and
stuff it in the environment variable.
HTH,
Barrie