Install mod_cloudflare on CWP Apache Web Server

by Sandeep B.

mod_cloudflare Apache module will restore the remote ip and it will also fix https issue with Cloudflare flexible ssl.

Based on mod_remoteip.c, this Apache extension will replace the remote_ip variable in user’s logs with the correct remote IP sent from CloudFlare. The module only performs the IP substitution for requests originating from CloudFlare IPs by default.

In addition to this, the extension will also set the HTTPS environment variable to “on” in cases where Flexible SSL is in use. This prevents software such as WordPress from being broken by Flexible SSL.

Cloudflare Restoring original visitor IPs with mod_remoteip in CWP/Apache

To install,  Follow this steps :

Step one install required dependencies :

yum install libtool git -y

Download C Lone cloudflare Apache module from git :

cd /usr/local/src
git clone && cd mod_cloudflare

Install Mod_cloudflare :

/usr/local/apache/bin/apxs -a -i -c mod_cloudflare.c

Restart apache service and check the module installed or not :

service httpd restart && /usr/local/apache/bin/httpd -M|grep cloudflare

eg. output :

[root@srv mod_cloudflare]# service httpd restart && /usr/local/apache/bin/httpd -M|grep cloudflare
Redirecting to /bin/systemctl restart httpd.service
 cloudflare_module (shared)

If this post helps you in any way please consider a donation

Donate with PayPal :


You may also like


Tnow July 26, 2019 - 12:44 pm Reply
Sandy July 27, 2019 - 9:00 am

if you’re using nginx webserver then use this post or otherwise use apache one

Tnow July 28, 2019 - 2:23 am

Web Servers: nginx-varnish-apache

What do you recommend I use, this post or the other one?

Tnow July 28, 2019 - 2:28 am

Can I do both? Will that be a problem or redundant and shouldn’t?

jonatito September 4, 2020 - 8:08 pm


i don’t get the real ip

What I can do?

Thank you

Sandeep B. September 5, 2020 - 7:12 am

is the module loaded ?

jonatito September 6, 2020 - 7:37 pm

yes, it is loaded


Leave a Comment