Applicable to:
- Plesk for Linux
Question
How to set up nginx to log real client IP address when the Plesk server is behind an external proxy server?
Answer
-
Go to Domains > example.com > Hosting & DNS > Apache & nginx Settings.
-
Add the following lines to the additional nginx directives field:
CONFIG_TEXT: 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.
-
-
Apply the changes.
-
Go to Domains > example.com > Hosting & DNS > Apache & nginx Settings.
-
Add the following lines to the additional directives for HTTP/HTTPS fields:
CONFIG_TEXT: 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.
-
Apply the changes.
-
Connect to the server via SSH.
-
Create the file with additional nginx configuration:
# touch /etc/nginx/conf.d/ext_proxy_server.conf
-
Open the file in a text editor. In this example, we are using vi editor:
# vi /etc/nginx/conf.d/ext_proxy_server.conf
-
Add the following lines to the additional nginx directives:
CONFIG_TEXT: 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.
-
Save the changes and close the file.
-
Restart nginx service:
# service nginx restart
Comments
0 comments
Please sign in to leave a comment.