I recently faced an issue where the IP addresses logged in Frappe were showing Cloudflare’s proxy IPs instead of the actual client IPs. After some research, I found that Nginx needs to be properly configured to use the real client IP when behind Cloudflare.
If we’re using Cloudflare as a reverse proxy for our Frappe/ERPNext setup in Ubuntu, we need to open Nginx configuration
/etc/nginx/conf.d/frappe-bench.conf
and add the following lines
set_real_ip_from 0.0.0.0/0;
real_ip_header CF-Connecting-IP;
to correctly capture the visitor’s real IP:
Restart Nginx to apply changes:
sudo systemctl restart nginx
and open site config file
/home/frappe/frappe-bench/sites/your-site-name/site_config.json
and add follwoing lines:
"host_name": "https://yourdomain.com",
"use_x_forwarded_for": 1
save and restart
sudo supervisorctl restart all