Welcome! Log In Create A New Profile

Advanced

Nginx real_ip module doesn't work in some conditions

August 27, 2016 03:02PM
So I have Nginx proxy and some servers running behind it. I need to know real users IP not proxy, so I using real_ip module. Everything is working as expected, but if I configure vhost like subdomain.domain.com backend getting Nginx proxy IP.

Here is my Nginx config sample

set_real_ip_from 192.168.2.0/24;
real_ip_header X-Forwarded-For;
real_ip_recursive on;

upstream srv1 { server 192.168.2.12:80; }

server {

listen 80;
server_name dev.somedomain.com;

location / {
proxy_pass http://srv1;
}

}

server {

listen 80;
server_name somedomain.com;

location / {
proxy_pass http://srv1;
}

}

So if I go to somedomain.com backend receiving real IP, no problems here. But for dev.somedomain.com backend receiving proxy IP!

And this is only shortened example, same situation with different domains and subdomains...
Subject Author Posted

Nginx real_ip module doesn't work in some conditions

romkaltu August 27, 2016 03:02PM

Re: Nginx real_ip module doesn't work in some conditions

Francis Daly August 27, 2016 07:06PM

Re: Nginx real_ip module doesn't work in some conditions

romkaltu August 28, 2016 04:13AM

Re: Nginx real_ip module doesn't work in some conditions

Francis Daly August 28, 2016 04:52AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 76
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready