CloudFlare User True IP Easy Apache 4 CentOS 7 /cPanel 78

Kilberz

Registered
Mar 27, 2019
3
0
1
United Kingdom
cPanel Access Level
Root Administrator
Hi Everyone,

Please go easy, I've searched and found many conflicting posts on this and lots of them I found are no longer working solutions.

I'm trying to find a way to easily configure the server (cPanel 78 / CentOS 7) so that any site hosted be it behind CloudFlare or not will always reflect the users true IP.

I installed ea-apache24-devel then https://www.cloudflare.com/static/misc/mod_cloudflare/mod_cloudflare.c and ran apxs -a -i -c mod_cloudflare.c

This seemed like a working solution for some but has not given me what I need to the best of my knowledge / as far as I can see still got an internal 192.* IP.

Any help would be awesome, thank you.

Jason.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,258
463
Hello Jason,

You can revert the initial steps you took and instead install mod_remoteip with EasyApache 4 using the following command:

Code:
yum install ea-apache24-mod_remoteip
Once you do this, there's a post on the link below with an example of how to configure it to log the IP address of the visitor instead of the CloudFlare IP:

mod_cloudflare vs mod_remoteip

Thank you.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,258
463
I installed ea-apache24-devel then https://www.cloudflare.com/static/misc/mod_cloudflare/mod_cloudflare.c and ran apxs -a -i -c mod_cloudflare.c
How would I revert my prior actions?
You can remove the module from the /usr/lib64/apache2/modules/ directory, remove mod_cloudflare.conf, and then restart Apache. Here's an example:

Code:
# mkdir /root/cloudflare
# mv /usr/lib64/apache2/modules/mod_cloudflare.so /root/cloudflare/
# mv /etc/apache2/conf.modules.d/mod_cloudflare.conf /root/cloudflare/
# /scripts/restartsrv_httpd
Keep in mind this is untested because it's a custom module.

Thank you.