Showing Real IP Instead of CloudFlare IP's

tutorialsWe love Cloudflare! But, after many attempts to restore real visitor IP's via cPanel we just about gave up. We hated the thought of removing our sites from Cloudflare since there are so many positive benefits. I hate to even say it but, thinking the people at Cloudflare do not even understand how to restore real visitor IP reporting via cPanel. Their help docs did nothing for us. Found conflicting info and nothing seemed to work...

I will point out that we are on the free Cloudflare plan so please do not take this as ungrateful, just pointing out our journey in search of working solution.

It is VERY IMPORTANT that you have some basic knowledge of working with root access to your cPanel based server. If you do not understand the information below, it might be best if you referred your hosting provider to this article instead of doing it yourself. We DO NOT take any responsibility on how you use the information below.

Showing real visitor IP instead of CloudFlare IP's can be a very tricky. The mod_cloudflare in WHM/cPanel does not do the job for us or thousands of others according to search results. This tutorial is based on WHM/cPanel 58+ and Centos 6.X. If you are using any other system, highly recommend you contact your host provider to make sure below steps will work for you.

So, since you want to know how to show real IP instead of Cloudflare IP's...

NOTE: If you have already installed mod_clouldflare using Easy Apache, go now, uncheck cloudflare from within Easy Apache and recompile Apache without the mod. If you do not complete this step, do not expect the steps below to work.

Now we can install Mod_Cloudflare via RPM (telnet). You will of course need to login as root using a program such as Putty. If you do not have root access or understand, direct your host provider to this post!

1) Check for dependencies making sure the below module libtool httpd-devel is already installed:

# yum install libtool httpd-devel

2) Next step is to download mod_cloudflare to server:

# wget https://www.cloudflare.com/static/misc/mod_cloudflare/mod_cloudflare.c

3) Now we need to edit mod_cloudflare.c by adding ALL your servers IP's to the of the list Cloudflare provides within the script. show real ip not cloudflare Simply add your IP(s) after the last CF IP: static const char CF_DEFAULT_TRUSTED_PROXY[] = { / IPv4 Address Ranges */ "00.00.00.123", "00.00.00.321", "next ip", "etc.", Exit out of mod_cloudflare.c and be sure to save your modification.

4) Now we need to save the modified file and install module for httpd config:

# apxs -a -i -c mod_cloudflare.c

5) Once the installation has completed, you will see a successful notification. Now let's restart some services:

a) Restart apache >

# service httpd restart

b) Stop railgun (if applicable) >

# service railgun stop

c) Restart memcached >

# service memcached restart

d) Restart railgun (if applicable) >

# service railgun start

6) Last step but VERY IMPORTANT.

Run cPanel distiller so that the modifications are made to the Apache configuration file httpd.conf. Future events like adding and removing a domain via cPanel, the new httpd.conf is dynamically written so custom changes are kept using the distiller:

# /usr/local/cpanel/bin/apache_conf_distiller --update

That should restore your visitors (and crawlers) IP's instead of Cloudflare's. You can verify by checking our your "Server Status / Apache Status" logs via WHM interface.

Although it is not necessary, we normally do a "Graceful Server Reboot" after making changes like above. Totally up to you but we think a very good practice.

If you need reliable web hosting, be sure to visit our sister site here.