Plesk - Cloudflare Show original visitor IP address
Foreword
The following help center article describes how to display the actual IP addresses of your website visitors in the web server logs if you are running Cloudflare as a reverse proxy in front of your Plesk server.
Prerequisites
- Server with Plesk Control Panel
Implementation
Open your Plesk Control Panel in the browser and navigate to Websites & Domains โ Your Domain โ Hosting and DNS โ Apache & nginx.
Then navigate down to the additional nginx instructions and add the following entries there.
# Set X-Forwared-For header in relation to "real_ip_header" module
real_ip_header X-Forwarded-For;
# Set the Cloudflare IP addresses for which the original IP address should be displayed
set_real_ip_from <IPv4 or IPv6>;
set_real_ip_from <IPv4 or IPv6>;
It is important to note here that all current IPv4 and IPv6 addresses are stored so that the real IP address can also be displayed in the web server log for all connections.
If you have a command line available, you can execute the following command to generate all the necessary set_real_ip_from
entries for the current IP addresses:
curl -s https://www.cloudflare.com/ips-v4/# | sed 's|^|set_real_ip_from |; s|$|;|' && echo
curl -s https://www.cloudflare.com/ips-v6/# | sed 's|^|set_real_ip_from |; s|$|;|' && echo
The list of IP addresses in the screenshot above is incomplete and may contain outdated entries. Please note the text in the blue information box and, if possible, use the suggested commands to obtain the current IP addresses or the corresponding entries.
Finally, save the adjustments by clicking on the blue OK or Apply button.