You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by pangj <pa...@riseup.net> on 2012/10/13 13:41:33 UTC

X-Forwarded-For

Hi,

We have nginx as the reverse proxy in front of apache modperl servers.
In nginx's config file we have added the x-forwarded-for header.
With modperl (MP2) how to get this header? I have forgot that.

Thanks.

Re: X-Forwarded-For

Posted by pangj <pa...@riseup.net>.
Thanks for all the answers.

于 2012-10-15 7:39, Cees Hek 写道:
> On Mon, Oct 15, 2012 at 8:25 AM, Perrin Harkins <perrin@elem.com
> <ma...@elem.com>> wrote:
>
>     On Sat, Oct 13, 2012 at 7:41 AM, pangj <pangj@riseup.net
>     <ma...@riseup.net>> wrote:
>      > In nginx's config file we have added the x-forwarded-for header.
>      > With modperl (MP2) how to get this header?
>
>     Use headers_in():
>     http://perl.apache.org/docs/2.0/api/Apache2/RequestRec.html#C_headers_in_
>
>
> As an alternative, you could use something like mod_rpaf on your backend
> apache server:
>
> http://stderr.net/apache/rpaf/
>
> This will look for an X-Forwarded-For header and if it is from a trusted
> proxy server (ie a server specified in your config), it will update the
> remote client information that apache sees.  Makes ip addresses in your
> access log much more useful, and means you don't need custom code to
> look at proxy headers to figure out the real client ip address.
>
> Cheers,
>
> Cees Hek


Re: X-Forwarded-For

Posted by Cees Hek <ce...@gmail.com>.
On Mon, Oct 15, 2012 at 8:25 AM, Perrin Harkins <pe...@elem.com> wrote:

> On Sat, Oct 13, 2012 at 7:41 AM, pangj <pa...@riseup.net> wrote:
> > In nginx's config file we have added the x-forwarded-for header.
> > With modperl (MP2) how to get this header?
>
> Use headers_in():
> http://perl.apache.org/docs/2.0/api/Apache2/RequestRec.html#C_headers_in_
>
>
As an alternative, you could use something like mod_rpaf on your backend
apache server:

http://stderr.net/apache/rpaf/

This will look for an X-Forwarded-For header and if it is from a trusted
proxy server (ie a server specified in your config), it will update the
remote client information that apache sees.  Makes ip addresses in your
access log much more useful, and means you don't need custom code to look
at proxy headers to figure out the real client ip address.

Cheers,

Cees Hek

Re: X-Forwarded-For

Posted by Perrin Harkins <pe...@elem.com>.
On Sat, Oct 13, 2012 at 7:41 AM, pangj <pa...@riseup.net> wrote:
> In nginx's config file we have added the x-forwarded-for header.
> With modperl (MP2) how to get this header?

Use headers_in():
http://perl.apache.org/docs/2.0/api/Apache2/RequestRec.html#C_headers_in_

- Perrin