httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian V Hughes <bria...@Dartmouth.EDU>
Subject Re: [users@httpd] How add / foward in header the remote_addr with proxy mode ?!
Date Fri, 11 Mar 2005 14:23:35 GMT
On Mar 11, 2005, at 09:03 AM, Joshua Slive wrote:
> On Fri, 11 Mar 2005 12:10:12 +0100, david micheneau
> <dmicheneau@in-fusio.com> wrote:
>> I've tried this:
>>
>> RequestHeader add MyHeader-ip %{REMOTE_ADDR}e
>>
>> I see in the header HTTP forwarded my header name but the value is 
>> null:
>>
>> GET / HTTP/1.1
>> Max-forwards: 10
>> MyHeader-ip: (null)
>
> I believe that this capability is available only in the 2.1 version, 
> not in 2.0.
>
> But doesn't the proxy already add a similar header?  I think it is
> called X-Forwarded-For.

I do this all the time, under Apache 2.0.52. Actually, it was the 
people on this list that helped me with the syntax I needed to use, to 
both create my own environment variable (storing the value of the 
REMOTE_PORT server variable) and then setting that as a header using 
RequestHeader. Here's the set of directives I'm using, which is 
probably more than David needs, but I wanted to make sure I gave a 
complete example...

RewriteEngine on
RewriteCond %{REMOTE_PORT} (.*)
RewriteRule .* - [E=R_P:%1]

RequestHeader add X-Remote-Port %{R_P}e

When I then reverse-proxy this incoming request, to an app server 
running on a different port:

RewriteRule ^/(.*)$ http://127.0.0.1:8080/$1 [P,L]

The app server can access the client's remote port by grabbing the 
value of the "X-Remote-Port" HTTP header.

-Brian


---------------------------------------------------------------------
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


Mime
View raw message