nixCraft published a tutorial about restoring the real IP address when Nginx is behind a reverse proxy.
Nginx restore real IP address when behind a reverse proxy
Explains how to restore or get real IP address of users/clients when the Nginx web server is behind a reverse proxy such as Cloudfront/Fastly/Cloudflare.
Nginx restore real IP address when behind a reverse proxy - nixCraft