Welcome! Log In Create A New Profile

Advanced

Re: On proxy my nginx show wrong ip (private)

Francis Daly
November 23, 2010 07:54PM
On Tue, Nov 23, 2010 at 01:45:02PM -0500, dong wrote:

Hi there,

> Problem is in this that php scripts from apache (192.168.1.3) showing
> client IP from nginx (192.168.1.2). For example: phpBB showing on line
> users and ips 192.168.1.2.

The php scripts are probably using REMOTE_ADDR, which is the address of
the client connecting to Apache, which is nginx.

> Its my settings in nginx (192.168.1.2):
> --- START---
> server {
> listen 80;
> server_name www.skuter-forum.pl skuter-forum.pl;
> access_log /var/log/nginx/skuter-forum.pl.access.log;
>
> if ($host = 'www.skuter-forum.pl' ) {
> rewrite ^/(.*)
> http://skuter-forum.pl/$1 permanent;
> }

Aside -- there's a better way of doing that.

> location / {
> proxy_pass http://192.168.1.3:80;
> proxy_set_header X-Real-IP $remote_addr;
> proxy_set_header Host $http_host;
> }
> }
>
> --- END ---
>
> How set real clients ips?

You have told nginx to send the http header X-Real-IP with this
value. That's pretty much all you can do on the nginx side. So either
get your Apache to set that value as REMOTE_ADDR for the php scripts,
or get the php scripts to read HTTP_X_REAL_IP instead of REMOTE_ADDR.

Good luck,

f
--
Francis Daly francis@daoine.org

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

On proxy my nginx show wrong ip (private)

dong November 23, 2010 01:45PM

Re: On proxy my nginx show wrong ip (private)

Francis Daly November 23, 2010 07:54PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 127
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