set_real_ip CloudFlare #282
Replies: 2 comments 1 reply
-
I just set this up, and it does work. The script you linked to is using "/etc/nginx/cloudflare" as the file to store the addresses, but that is a folder in the cloudpanel system. I changed the line in the http block of "/etc/nginx/nginx.conf" to "include /etc/nginx/cloudflare/cloudflare-ips", and in the script "CLOUDFLARE_FILE_PATH=/etc/nginx/cloudflare/cloudflare-ips". Another thing that could throw you off is that, in the end of that guide they add a cron entry for "/opt/scripts/cloudflare-ip-whitelist-sync.sh", but their script is named "cloudflare-sync-ips.sh". Make sure to add the cron job with the correct path/file. I also did "chown root:root && chmod +x" on the script and added the cron job as root. You should run the script in a shell the first time to see if there are any errors. You might want to check the "/etc/nginx/nginx.conf" when updating CloudPanel in case it removes the include. |
Beta Was this translation helpful? Give feedback.
-
I just realized that when you set "Allow traffic from Cloudflare only" under site security settings, it will 403 because it's no longer seeing cloudflare addresses. Maybe that was OPs issue. |
Beta Was this translation helpful? Give feedback.
-
How get real visitor IP Address (Restoring Visitor IPs) with Nginx and CloudFlare?
On other servers with Nginx and CL, I can configure normally: https://github.com/ergin/nginx-cloudflare-real-ip
But doing the same procedure in CloudPanel I get the 403 error.
Beta Was this translation helpful? Give feedback.
All reactions