How to configure nginx for proxying one another, that correctly worked out the ip?

There are two different servers with nginx.
The first accepts queries and bind them to the second, which in turn Park them on local socket, that is not extremely important now.
The problem is that the second nginx is not accepting the correct ip. If Werth logs, he always is the ip address of the server, not the client who requested.

The host proxy has a full-time 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 spectrosc no no. I understand that it staff needs to work out this situation. On both servers the staff nginx version: nginx/1.4.6 from the repository.
What's wrong?
July 8th 19 at 15:45
1 answer
July 8th 19 at 15:47
try the "set_real_ip_from" Directive

Find more questions by tags IPNginxProxy