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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thanks it's working !

In httpd.conf 

    RewriteEngine on
    RewriteCond %{REMOTE_ADDR} (.*)
    RewriteRule .* - [E=R_A:%1]
    RequestHeader add MyHeader %{R_A}e

David.


-----Message d'origine-----
De : Brian V Hughes [mailto:brianvh@xxxxxxxxxxxxx] 
Envoyé : vendredi 11 mars 2005 15:24
À : users@xxxxxxxxxxxxxxxx
Objet : Re: [users@httpd] How add / foward in header the remote_addr with proxy mode ?!

On Mar 11, 2005, at 09:03 AM, Joshua Slive wrote:
> On Fri, 11 Mar 2005 12:10:12 +0100, david micheneau
> <dmicheneau@xxxxxxxxxxxx> 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@xxxxxxxxxxxxxxxx
   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx


---------------------------------------------------------------------
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@xxxxxxxxxxxxxxxx
   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx



[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux