Cobra Forum

Plesk Panel => Webserver => Topic started by: Suhitha on Sep 29, 2025, 05:56 AM

Title: How to set up nginx to log real client IP address when the Plesk server is
Post by: Suhitha on Sep 29, 2025, 05:56 AM
Question: How to set up nginx to log real client IP address when the Plesk server is behind an external proxy server


Applicable to:



Answer

For 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;
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;


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

Related to

Plesk for Linux