Cobra Forum

Plesk Panel => Webserver => Topic started by: mahesh on Nov 27, 2024, 06:23 AM

Title: How to set up nginx to log real client IP address when the Plesk server is behin
Post by: mahesh on Nov 27, 2024, 06:23 AM
Question
How to set up nginx to log real client IP address when the Plesk server is behind an external proxy server?

Answer
For one domain (nginx reverse proxy is enabled)
 
set_real_ip_from 192.0.2.2/8;
real_ip_header X-Forwarded-For;
real_ip_recursive on;

4.Apply the changes.

For one domain (nginx reverse proxy is disabled)



RemoteIPHeader X-Forwarded-For
RemoteIPInternalProxy 192.0.2.2/8;

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;

5.Save the changes and close the file.

6.Restart nginx service:

#service nginx restart