You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Jeff Bisbee <mo...@jbisbee.com> on 2005/01/07 01:39:50 UTC

Simple mod_perl Question

I just wanted to verify that there weren't any hidden gotchas by doing
the following:

    # set actual ip of host doing the requesting instead of the proxy
    my ($actual_remote_ip) = split /,/, $r->header_in('X-Forwarded-For');
    $r->connection->remote_ip($actual_remote_ip) if $actual_remote_ip;

I just wanted to make sure there would be any conditions that the above 
code wouldn't handle.

-- Jeff Bisbee / mod_perl-users@jbisbee.com / jbisbee.com

Re: Simple mod_perl Question

Posted by Perrin Harkins <pe...@elem.com>.
On Fri, 2005-01-07 at 13:38 -0500, Jeff Bisbee wrote:
> * Jeff Bisbee (mod_perl-users@jbisbee.com) wrote:
> > I just wanted to verify that there weren't any hidden gotchas by doing
> > the following:
> > 
> >     # set actual ip of host doing the requesting instead of the proxy
> >     my ($actual_remote_ip) = split /,/, $r->header_in('X-Forwarded-For');
> >     $r->connection->remote_ip($actual_remote_ip) if $actual_remote_ip;
> > 
> > I just wanted to make sure there would be any conditions that the above 
> > code wouldn't handle.
> 
> I guess I just want some quick feedback to make sure I'm going about
> replacing the IP the right way and there isn't a better way to do it.

I've never tried it, but I assume it will work because it's in the docs:
http://perl.apache.org/docs/1.0/guide/scenario.html#Getting_the_Remote_Server_IP_in_the_Back_end_server_in_the_Proxy_Setup

- Perrin


Re: Simple mod_perl Question

Posted by Jeff Bisbee <mo...@jbisbee.com>.
* Jeff Bisbee (mod_perl-users@jbisbee.com) wrote:
> I just wanted to verify that there weren't any hidden gotchas by doing
> the following:
> 
>     # set actual ip of host doing the requesting instead of the proxy
>     my ($actual_remote_ip) = split /,/, $r->header_in('X-Forwarded-For');
>     $r->connection->remote_ip($actual_remote_ip) if $actual_remote_ip;
> 
> I just wanted to make sure there would be any conditions that the above 
> code wouldn't handle.

I guess I just want some quick feedback to make sure I'm going about
replacing the IP the right way and there isn't a better way to do it.

-- Jeff Bisbee / mod_perl-users@jbisbee.com / jbisbee.com