Question: How to set up nginx to log real client IP address when the Plesk server is behind an external proxy server
Applicable to:AnswerFor one domain (nginx reverse proxy is enabled)
1.Log in to Plesk.
2.Go to Domains > example.com > Hosting & DNS > Apache & nginx Settings.
3.Add the following lines to the additional nginx directives field:
set_real_ip_from 192.0.2.2/8;
real_ip_header X-Forwarded-For;
real_ip_recursive on;
- where 192.0.2.2/8 is an IP address of the external proxy server.
4.Apply the changes.
For one domain (nginx reverse proxy is disabled)1.Log in to Plesk.
2.Go to Domains > example.com > Hosting & DNS > Apache & nginx Settings.
3.Add the following lines to the additional directives for HTTP/HTTPS fields:
RemoteIPHeader X-Forwarded-For
RemoteIPInternalProxy 192.0.2.2/8;
- where 192.0.2.2/8 is an IP address of the external proxy server.
4.Apply the changes.
For all domains (nginx reverse proxy is enabled) 1.Connect to the server via SSH.
2.Create the file with additional nginx configuration:
# touch /etc/nginx/conf.d/ext_proxy_server.conf
3.Open the file in a text editor. In this example, we are using vi editor:
# vi /etc/nginx/conf.d/ext_proxy_server.conf
4.Add the following lines to the additional nginx directives:
set_real_ip_from 192.0.2.2/8;
real_ip_header X-Forwarded-For;
real_ip_recursive on;
- where 192.0.2.2/8 is an IP address of the external proxy server.
5.Save the changes and close the file.
6.Restart nginx service:
# service nginx restart
Related toPlesk for Linux