A simple code snippet that can be used to pass client and proxy IP addresses.

On the Nginx proxy add these definitions to pass client and proxy IP addresses:

proxy_set_header  X-Real-IP  $remote_addr;
proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;

On the second Nginx server you just need to add two lines:

set_real_ip_from; # proxy address
real_ip_header     X-Real-IP;

Where X-Real-IP, X-Forwarded-For contains client IP address and Host contains proxy IP address.