You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Garth Winter Webb <ga...@perijove.com> on 2003/07/29 19:01:11 UTC
[users@httpd] Passing REMOTE_ADDR in a ProxyPass
Hi, I've got a proxy server set up with several name based virtual
hosts. Each virtual host ProxyPass's to another apache instance that
serves the content. I would like to run a web log analyzer on one of
these apache instances behind the proxy server.
The problem is that the proxy server sets the REMOTE_ADDR environmental
variable to its IP address when it forwards the request along, when
really I want it to send the IP address of the machine that originally
requested the document. Since it sends its own IP, the log analyzer
thinks that every single request came from my proxy machine.
I've been unable to find any directives in:
http://httpd.apache.org/docs/mod/mod_proxy.html
that address this. I've also looked at RewriteRule with the 'E' flag to
pass along the REMOTE_ADDR information, but I can't seem to make it
work. This is my attempt:
RewriteRule ^/(.*) http://localhost:8525/$1
[P,E=REMOTE_ADDR:env=REMOTE_ADDR]
Thanks!
--
Garth Winter Webb <ga...@perijove.com>
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] Passing REMOTE_ADDR in a ProxyPass
Posted by Joshua Slive <jo...@slive.ca>.
On Tue, 29 Jul 2003, Garth Winter Webb wrote:
> I looked at the 'mod_proxy_add_forward.c' source and found that it
> appends any existing X-Forwarded-For headers to the value it creates.
> Apparently something else is setting this header correctly. I reverted
> to the old build of apache without 'mod_proxy_add_forward.c' and now I
> get log entries on my backend server with a single, correct IP address.
>
> I guess all I needed to do was change my log format!
A yes. Looking at the cvs logs, it was added in apache 1.3.25. Sorry for
the wild goose chase.
Joshua.
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] Passing REMOTE_ADDR in a ProxyPass
Posted by Garth Winter Webb <ga...@perijove.com>.
Thanks for the information! I compiled that module in, and then changed
the log format of my backend server to:
LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b" common
when I restarted apache and tested, I found this curious format in the
log file:
192.168.1.168, 192.168.1.168 - - [29/Jul/2003:10:58:07 -0700] "GET /
HTTP/1.1" 200 8724
I looked at the 'mod_proxy_add_forward.c' source and found that it
appends any existing X-Forwarded-For headers to the value it creates.
Apparently something else is setting this header correctly. I reverted
to the old build of apache without 'mod_proxy_add_forward.c' and now I
get log entries on my backend server with a single, correct IP address.
I guess all I needed to do was change my log format!
On Tue, 2003-07-29 at 10:08, Joshua Slive wrote:
> On Tue, 29 Jul 2003, Garth Winter Webb wrote:
> > RewriteRule ^/(.*) http://localhost:8525/$1
> > [P,E=REMOTE_ADDR:env=REMOTE_ADDR]
>
> No way that will work. For starters, environment variables are certainly
> not passed in http request; they are local to the server where they are
> set.
>
> What you want is to upgrade to have the X-Forwarded-For HTTP header added
> to the requests. I believe that apache 2 does this automatically. For
> 1.3, you can look at
> http://develooper.com/code/mpaf/mod_proxy_add_forward.c
>
> Once you have that, you can put it in your logfile using the format string
> %{X-Forwarded-For}i
>
> Joshua.
>
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> " from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
--
Garth Winter Webb <ga...@perijove.com>
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] Passing REMOTE_ADDR in a ProxyPass
Posted by Joshua Slive <jo...@slive.ca>.
On Tue, 29 Jul 2003, Garth Winter Webb wrote:
> RewriteRule ^/(.*) http://localhost:8525/$1
> [P,E=REMOTE_ADDR:env=REMOTE_ADDR]
No way that will work. For starters, environment variables are certainly
not passed in http request; they are local to the server where they are
set.
What you want is to upgrade to have the X-Forwarded-For HTTP header added
to the requests. I believe that apache 2 does this automatically. For
1.3, you can look at
http://develooper.com/code/mpaf/mod_proxy_add_forward.c
Once you have that, you can put it in your logfile using the format string
%{X-Forwarded-For}i
Joshua.
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org