This is specific question.
A Nginx server (call it N1) listens on :80 and forwards to varnish with proxy_pass Varnish listens on 127.0.0.1:6081 and forwards to Nginx (N2) on 8080. N2 talks to the php-fpm socket.
N1<>V<>N2<>P
N1:
location / { 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; proxy_pass http://varnish/; proxy_redirect off; }
currently
$_SERVER['REMOTE_ADDR'] == '127.0.0.1'
desired
$_SERVER['REMOTE_ADDR'] == 'The real remote addr'