Welcome! Log In Create A New Profile

Advanced

Re: Pass real client IP to web servers

Maxim Dounin
March 26, 2009 06:49AM
Hello!

On Wed, Mar 25, 2009 at 07:53:31PM -0400, bdroste wrote:

> Subject: Pass real client IP to web servers
> Author: bdroste
>
> I'm sure this has been asked before, but I can't find an answer. I'm running nginx-0.7.44 on a server, load balancing port 80 to port 8080 on 2 other servers running Apache. I am trying to figure out how to get Nginx to pass the real IP address of the browser client through to the web servers. The web servers always log the IP address of the Nginx server instead of the client.
>
> A Google search suggested that I needed to run a Apache proxy server on each of my web servers that then pass the request on to my real web server, so the headers are rewritten. That works, but it seems I should be able to do this with Nginx and not need to run an intermediate web server just to pass the traffic to my real web servers.

[...]

> proxy_set_header X-Real-IP $remote_addr;
> proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

You should configure Apache to accept ip address from X-Real-IP or
X-Forwarded-For headers set by nginx (and from nginx server ip).
Take a look at mod_realip or mod_rpaf/mod_rpaf2 apache modules.

As you said that running Apache proxy on each of your web servers
fixes the issue - probably you already have one of the modules
above, but configured to accept X-Real-IP/X-Forwarded-For from
localhost only.

Maxim Dounin
Subject Author Posted

Pass real client IP to web servers

bdroste March 25, 2009 07:53PM

Re: Pass real client IP to web servers

mike March 26, 2009 02:01AM

Re: Pass real client IP to web servers

Maxim Dounin March 26, 2009 06:49AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 135
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready