Restore Visitors’ Original IP from CloudFlare in Apache 2.4
Earlier I made a post on My Problems with CloudFlare and this was one them, I guess they saw my post and decided to do something 😀 . Meanwhile if you are in Business Enterprise Plan in CloudFlare you can activate for the user’s real IP be sent to you via Header but, poor me… I’m just a free user but thanks for CloudFlare for at least remembering me 🙂 .
This is application not only to Ubuntu but also to RedHat, CentOS and other Yum and Deb systems 🙂 We are gonna be installing some tools and libraries by typing:
$ sudo apt-get install apache2-dev libtool git
Yum Systems
$ sudo yum install apache2-dev libtool git
Above we installed Apache2 Dev Tools because the mod_cloudflare is still in its source code and not compiled into a module yet, only dev tool can be used to install it.
Now we are going to copy/clone the source file from the Git repo and install:
git clone https://github.com/cloudflare/mod_cloudflare.git && cd mod_cloudflare
Using Apache extension to convert the source file to module and install by typing:
$ sudo apxs -aic mod_cloudflare.c
Restart Apache and check if module is enabled
Debian/Ubuntu
sudo service apache2 restart && apache2ctl -M | grep cloudflare
RedHat/CentOS
$ sudo service httpd restart && httpd -M | grep cloudflare