When you use CloudFlare CDN it acts as a proxy to your content and distributes it all around the world. Therefore in your raw HTTP access logs you’ll see the CloudFlare hostnames as opposed to the original IP address.
Although you have analytics installed sometimes it’s important (and legally required sometimes) to have full logs available. Following the steps below will change your access logs from:
cf-173-245-53-63.cloudflare.com – – [10/Sep/2011:20:23:44 +0100] “GET /wp-content/themes/premiumpixels/images/bg-side-bevel.gif HTTP/1.0” 200 35
cf-173-245-53-63.cloudflare.com – – [10/Sep/2011:20:23:44 +0100] “GET /wp-content/themes/premiumpixels/images/bg-footer.gif HTTP/1.0” 200 1698
cf-173-245-49-107.cloudflare.com – – [10/Sep/2011:20:23:44 +0100] “GET /wp-content/themes/premiumpixels/images/bg-foot-inner.jpg HTTP/1.0” 200 68030
cf-173-245-53-64.cloudflare.com – – [10/Sep/2011:20:23:45 +0100] “GET /favicon.ico HTTP/1.0” 200 –
cf-173-245-55-86.cloudflare.com – – [10/Sep/2011:20:30:34 +0100] “GET /favicon.ico HTTP/1.0” 200 –
cf-173-245-56-238.cloudflare.com – – [10/Sep/2011:20:31:09 +0100] “GET /tag/iseb HTTP/1.0” 200 6162
To something more ‘traditional’ like this:
2.27.164.2 – – [10/Sep/2011:20:38:23 +0100] “GET / HTTP/1.0” 200 7556
2.27.164.2 – – [10/Sep/2011:20:38:24 +0100] “GET /wp-includes/js/l10n.js?ver=20101110 HTTP/1.0” 200 221
2.27.164.2 – – [10/Sep/2011:20:38:24 +0100] “GET /wp-content/uploads/2011/08/Wordpress-FTP-details-dialogue-300×126.png HTTP/1.0” 200 22726
crawl-66-249-72-115.googlebot.com – – [10/Sep/2011:20:44:18 +0100] “GET /tag/mac HTTP/1.0” 200 6089
There is an excellent how to available over on the CloudFlare wiki, put here for ease of use.
logon via SSH to your box
Type in the following commands:
cd /root
wget http://github.com/cloudflare/CloudFlare-Tools/raw/master/mod_cloudflare.c
apt-get install apache2-prefork-dev
apxs2 -iac mod_cloudflare.c
sudo /etc/init.d/apache2 restart
(Update 30 Dec 2013 – There is now an easier way, thanks Dan.)
Type in the following commands:
cd /root
wget https://www.cloudflare.com/static/misc/mod_cloudflare/ubuntu/mod_cloudflare-precise-amd64.latest.deb
dpkg -i mod_cloudflare-precise-amd64.latest.deb
apt-get install apache2-prefork-dev
apxs2 -iac mod_cloudflare.c
sudo /etc/init.d/apache2 restart
Test it:
tail -f /[path to apache logs/access.log
Open up a website you host and you should now see the original IP address in your logs.
12 Comments
[…] http://www.gypthecat.com/how-to-install-mod_cloudflare-on-apache-for-ubuntu Share this:TwitterFacebookLike this:LikeBe the first to like this. […]
It seems the link you’ve included from github no longer works, this link does:
https://www.cloudflare.com/static/misc/mod_cloudflare/ubuntu/mod_cloudflare-precise-amd64.latest.deb
Via this page: https://www.cloudflare.com/resources-downloads
Thanks Dan, will update the main post. Was there any other dependencies or was installing the deb with something like dpkg -i suitable?
Nope that was it, incredibly easy to install 🙂
Excellent news 🙂 Thanks again, main post updated.
Got this error mate
[code]~# apxs2 -iac mod_cloudflare.c
Use of uninitialized value $includedir in concatenation (.) or string at (eval 9) line 1.
/usr/share/apr-1.0/build/libtool –silent –mode=compile –tag=disable-static x86_64-linux-gnu-gcc -prefer-pic -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -D_REENTRANT -I/usr/include -I/usr/include/apr-1.0 -I/usr/include/openssl -I/usr/include/xmltok -pthread -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -D_REENTRANT -I -I. -I/usr/include -I/usr/include/apr-1.0 -I/usr/include/apache2 -I/usr/include/apr-1.0 -I/usr/include/apr-1.0 -I/usr/include -c -o mod_cloudflare.lo mod_cloudflare.c && touch mod_cloudflare.slo
x86_64-linux-gnu-gcc: error: mod_cloudflare.c: No such file or directory
x86_64-linux-gnu-gcc: fatal error: no input files
compilation terminated.
apxs:Error: Command failed with rc=65536
.
[/code]
Hi Wuebit,
I’d guess it’s because CloudFlare no longer supports that method.
Try the method from December 2013 courtesy of Dan in the main post.
Gyp
Hi gyp I did follow your December 2013 tut 🙁
In that case I’m a bit lost sorry 🙁
You could try https://forum.linode.com/viewtopic.php?p=46365
That looks pretty similar but it is a bit old I appreciate.
Gyp
Same mate no idea also. Cheers Tho for the help
anyone know where the module is for apache 2.4 package on ubuntu, unable to find it anywhere.
Hi Bill,
Sorry for the tardy response, have you tried:
https://www.cloudflare.com/static/misc/mod_cloudflare/ubuntu/mod_cloudflare-precise-amd64.latest.deb
?
Gyp