remote_addr will refer to the proxy server, but you can configure the proxy server to send the client address with the X-Real-IP / X-Forwarded-For header fields.
In combination with the ngx_http_realip module, you can change the incoming header to use the real client address for remote_addr. I believe this will work as expected with allow / deny syntax.
Just to clarify - the allow / deny syntax should be identical after you enable and configure the module. Substitute your IP address and your proxy addresses below.
Back-end nginx enable / disable:
location / { allow <your ip>; allow 127.0.0.1; deny all; }
Nginx realip back-end configuration:
set_real_ip_from <your proxy>; real_ip_header X-Forwarded-For;
In your nginx proxy configuration:
proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
If you have several intermediate proxies, you need to enable the additional addresses real_ip_recursive and whitelist using the set_real_ip_from directive.
ngraves
source share