7
7
7761662016-06-08 13:37:22
proxy
776166, 2016-06-08 13:37:22

How to properly configure proxying of one nginx to another, so that ip is processed correctly?

There are two different servers with nginx.
The first accepts requests and forwards them to the second, which, in turn, parks them on a local socket, which is not very important now.
The problem is that the second nginx is not accepting the correct ip. If you believe the logs, it always turns out to be equal to the ip-address of the server itself, and not the client that made the request.

The receiving proxy has a default setting:

location / {
       proxy_pass http://IP:PORT;
       proxy_set_header Host $host;
       proxy_set_header X-Real-IP $remote_addr;
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

The second nginx has no special settings. I understand that he should work out such a situation on a regular basis. On both servers, the standard nginx version: nginx/1.4.6 from the repository.
What's wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton, 2016-06-12
@776166

try the directive set_real_ip_from
nginx.org/ru/docs/http/ngx_http_realip_module.html

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question