You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Michael Smith <mj...@iii.co.uk> on 1998/09/16 19:12:23 UTC

Original IP address through a proxy?

Hi Chaps (Chapesses?),

Long time since I've asked a stupid question (I usually reserve them for
the mod_perl list), so here goes.

I'm using mod_proxy as a reverse proxy server such that certain requests
are processed on a different apache server to that visible to the
outside world, so it looks something like this:

Client ------> HTTP server 1 ------> HTTP server 2

So the request is actually processed on HTTP server 2.  Now I'd like
HTTP server 2 to be able to know the IP address of the Client, for
logging and so forth.  In my setup, REMOTE_ADDR contains the IP address
of HTTP server 1, and there aren't any environment variables which
contain the IP address of the Client.

I can think of a few ways of doing this, but they're pretty messy.  HTTP
server 1 could add the IP address at the front of the URI, and then HTTP
server 2 could take it off again and stick it in to an environment
variable, but this seems *really* nasty (even by the standards of some
of the nasty things I do).

So, I feel there ought to be a clean way of being able to do this kind
of thing.  Any of you people-that-know-what-you're-doing have any
suggestions/thoughts?

Much appreciated, as ever

Mike





Re: Original IP address through a proxy?

Posted by Ask Bjoern Hansen <as...@netcetera.dk>.
On Wed, 16 Sep 1998, Michael Smith wrote:

> I'm using mod_proxy as a reverse proxy server such that certain requests
> are processed on a different apache server to that visible to the
> outside world, so it looks something like this:
> 
> Client ------> HTTP server 1 ------> HTTP server 2
> 
> So the request is actually processed on HTTP server 2.  Now I'd like
> HTTP server 2 to be able to know the IP address of the Client, for
> logging and so forth.  In my setup, REMOTE_ADDR contains the IP address
> of HTTP server 1, and there aren't any environment variables which
> contain the IP address of the Client.

It's pretty easy if you use mod_perl. (you mentioned that on the first
lines)

Get the latest version from cvs <http://perl.apache.org/mod_perl_cvs.html>
and $c->remote_ip is 'setable'.

You can then get http1 to add an extra header which http2 can read and set
remote_ip after - and REMOTE_ADDR and everything will be right.

=item $c->remote_ip

The dotted decimal representation of the remote client's IP address.
This is set by then server when the connection record is created so
is always defined.

You can also set this value by providing an argument to it. This is
helpful if your server is behind a squid accelerator proxy which add
a HTTP_X_FORWARDED_FOR header.   


Please followup to the modperl list if you continue on the modperl path.


hth,

ask

-- 
ask bjoern hansen - http://www.netcetera.dk/