Re: How do i know the original clients IP address?

Theo Schlossnagle <[email protected]> Wed, 01 Sep 2004 09:32:21 -0400
Newsgroups gmane.comp.apache.mod-backhand.general
Message-ID <[email protected]>
Alan Williamson wrote:

> Hit a small snag with using mod_backhand.
>
> In the pool of available servers, i have no idea what the client's IP 
> address is.  When i look at the CGI information, the remote address is 
> the IP address of the mod_backhand machine that proxied the request.
>
> Is there anyway I can find this information out?  If not, where would 
> one suggest I add this in the original source as a custom HTTP header 
> to be passed on down to the server processing the request.

BackhandProxied should be set to the original client's address
ProxiedFrom should be set to the front-end machine's address.

And if you are running mod_backhand on all the servers (back and front) 
your REMOTE_ADDR in cgi _should_ be updated.  When mod_backhand 
receieves are request from another mod_backhand server it will:

Set the r->connection->remote_addr to the BackhandProxied header if and 
only if the connecting address (front end proxy) is in one of the 
AcceptStats ranges specified in the conf file.  This happens in 
post_read_request (before any other handler, but _not_ before any module 
that uses post_read_request before mod_backhand.  It then resets the IP 
address back to the connection IP (proxy) so that there is no risk of IP 
spoofing if a request comes in without one of those headers on the same 
kept-alive HTTP connection.  This happens in the log handler.

So, YMMV, but try putting mod_backhand add the _very very_ top of the 
AddModule list.  This will make it run last.  Specifically try making it 
run after the mod_log_config (this means above it in the httpd.conf file).

The other option is to use the mod_proxy_add_forward module.  This is 
universal and will help solve the problem with mod_proxy and other such 
things too:

http://develooper.com/code/mpaf/mod_proxy_add_forward.c

-- 
// Theo Schlossnagle
// Principal Engineer -- http://www.omniti.com/~jesus/
// Postal Engine -- http://www.postalengine.com/
// Ecelerity: fastest MTA on Earth