Plesk is a good website control panel for self-managing your Linux/Windows VPS or dedicated server. It comes especially handy if you’re running Node.js CMS, WordPress blogs and have no time for managing server security, upgrades yet you want to utilize server resources efficiently via UI frontend

Plesk Control Panel Domain Settings

Advertisement

I was recently managing a client’s website who was serving their website using Plesk control panel with default Apache+Nginx reverse proxy configuration. Domain was also masked with CloudFlare DNS for firewall and CDN caching. Everything was butter smooth except this.

Problem:

Plesk Obsidian 18.0.49 was forwarding/logging incorrect website Visitor’s IP address. The Website logs were showing CloudFlare’s IP addresses instead of original visitor IP.

Plesk Domain Access Logs

2023-02-27 21:13:16 Access 103.22.200.164 < wrong IP> 200 GET /index.html HTTP/2.0 15.4 K nginx SSL/TLS access

 

Solution:

  • Login to Plesk Control Panel via URL [Example: https://YourServerIP:8443/login]
  • Click “Websites & Domains“, Click your Website Domain to expand its settings.
  • Open “Hosting and DNS” tab, then click “Apache and Nginx Settings
  • Scroll to the bottom of the page till you see “Additional nginx directives

Now enter this this line into the additional directives text box as it is.

Code for showing real Visitor IP with CloudFlare:

For Default Plesk (Nginx+Apache):

real_ip_header CF-Connecting-IP;

cloudflare nginx plesk ip

For Apache only server configuration:

RemoteIPHeader CF-connecting-IP

cloudflare apache real visitor ip fix plesk

Remember: You have to add the above line of code to both Additional directives for HTTP and Additional directives for HTTPS.

  • Finally, Restart your Plesk Server for the changes to take effect. Tools & Settings > Server Manangement > Restart Server
  • Now go to Website Logs, you will see correct Visitor’s IP addresses.

Note: This solution works on all Linux Plesk Web Admin SE, Web Admin Pro, Web Host including Obsidian/Onyx releases. The default installation have all the required modules and extensions preinstalled for forwarding the correct CF’s IP address, you just have to add a one-line directive in the Web server configuration which can be quickly done through the control panel interface. Making changes to Plesk files from root access (SSH) is not recommended and may break your server installation.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.