You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by david micheneau <dm...@in-fusio.com> on 2005/03/11 12:10:12 UTC

[users@httpd] How add / foward in header the remote_addr with proxy mode ?!

I know that is possible to make own header HTTP.
I want to add in header HTTP, that I forward, my own header variable set
with the value of the environment variable REMOTE_ADDR.

It's possible ??

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)

What is wrong ?


---------------------------------------------------------------------
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] How add / foward in header the remote_addr with proxy mode ?!

Posted by Brian V Hughes <br...@Dartmouth.EDU>.
On Mar 11, 2005, at 09:03 AM, Joshua Slive wrote:
> On Fri, 11 Mar 2005 12:10:12 +0100, david micheneau
> <dm...@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


Re: [users@httpd] How add / foward in header the remote_addr with proxy mode ?!

Posted by Joshua Slive <js...@gmail.com>.
On Fri, 11 Mar 2005 12:10:12 +0100, david micheneau
<dm...@in-fusio.com> wrote:
> I know that is possible to make own header HTTP.
> I want to add in header HTTP, that I forward, my own header variable set
> with the value of the environment variable REMOTE_ADDR.
> 
> It's possible ??
> 
> 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.

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