Behind a reverse proxy, the user IP we get is often the reverse proxy IP itself. But for obvious reasons it’s important to have access to the user real ip address.
Nging reverse proxy configuration
Tested for nginx/1.11.8
http_realip_module must be installed (
--with-http_realip_module), of course !
Use this command to check :
2>&1 nginx -V | tr -- - '\n' | grep http_realip_module
- We need to tell the reverse proxy to pass information to the backend nginx server.
- We can add thoses lines as a global configuration or per location.
Nginx backend configuration
- We can add a custom log format and use it in addition with others.
- Or we can override the default log format.
In some cases you will need to add this configuration :