• Home
  • The Song
  • The Avatar
  • The Cat
  • Contact the Cat

Gyp the Cat dot Com

How to install mod_cloudflare on Apache for Ubuntu
Business, internet

How to install mod_cloudflare on Apache for Ubuntu

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.

Related

Written by gyp - September 11, 2011 - 5828 Views
Tags | apache2, cloudflare, ubuntu

You Might Also Like

Blocking Countries on Nginx without the GeoIP Module

April 25, 2015
Control versus Escape

An Immature Way to Use Sudo

July 17, 2015

Installing LEMP on Ubuntu 14.04 with Nginx and NAXSI

June 20, 2015

12 Comments

  • How to Install Mod CloudFlare – Apache « aaronprice04 December 22, 2012 at 9:07 pm

    […] http://www.gypthecat.com/how-to-install-mod_cloudflare-on-apache-for-ubuntu Share this:TwitterFacebookLike this:LikeBe the first to like this. […]

    Reply
  • Dan Clarke December 20, 2013 at 12:41 pm

    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

    Reply
    • gyp December 30, 2013 at 2:21 pm

      Thanks Dan, will update the main post. Was there any other dependencies or was installing the deb with something like dpkg -i suitable?

      Reply
      • Dan December 30, 2013 at 2:39 pm

        Nope that was it, incredibly easy to install 🙂

        Reply
        • gyp December 30, 2013 at 2:57 pm

          Excellent news 🙂 Thanks again, main post updated.

          Reply
  • Wuebit July 28, 2014 at 6:05 pm

    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]

    Reply
    • gyp July 28, 2014 at 8:31 pm

      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

      Reply
      • Wuebit July 28, 2014 at 8:35 pm

        Hi gyp I did follow your December 2013 tut 🙁

        Reply
        • gyp July 28, 2014 at 8:59 pm

          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

          Reply
          • Wuebit July 29, 2014 at 8:47 am

            Same mate no idea also. Cheers Tho for the help

  • Bill September 24, 2014 at 3:05 pm

    anyone know where the module is for apache 2.4 package on ubuntu, unable to find it anywhere.

    Reply
    • gyp October 12, 2014 at 1:38 pm

      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

      Reply

    Please Post Your Comments & Reviews
    Cancel reply

    Your email address will not be published. Required fields are marked *

    Previous Post
    Next Post

    Latest Posts

    • Kusto Geolocation IP Lookup
    • Monitoring Tor Usage in Azure Sentinel, ASC, MDATP and ALA
    • HTTP to HTTPS Redirect on Azure CDN
    • Strongswan IPSec (Including Cryptomap) to Microsoft Azure Virtual Network Gateway
    • Black Ops 3 NAT Type Strict & PS4 NAT Type 3 with pfSense Fixed!
    • Sorry for the lack of posts
    • How to Block Internet Access with Group Policy (GPO)
    • Enforcing Microsoft Office 365 and Azure Tennancy with McAfee Web Gateway (MWG)
    • Scanning Subnet for Issuing Certificate Authority with OpenSSL
    • How to Configure Windows 2012 NPS for Radius Authentication with Ubiquiti Unifi

    Top Posts & Pages

    • How to Block Internet Access with Group Policy (GPO)
      How to Block Internet Access with Group Policy (GPO)
    • How to Configure Windows 2012 NPS for Radius Authentication with Ubiquiti Unifi
      How to Configure Windows 2012 NPS for Radius Authentication with Ubiquiti Unifi
    • Kusto Geolocation IP Lookup
      Kusto Geolocation IP Lookup
    • Tinyproxy A Quick and Easy Proxy Server on Ubuntu
      Tinyproxy A Quick and Easy Proxy Server on Ubuntu
    • Monitoring Tor Usage in Azure Sentinel, ASC, MDATP and ALA
      Monitoring Tor Usage in Azure Sentinel, ASC, MDATP and ALA
    • How to DNSPerf on Ubuntu 14.04 with Installation and Quick Start
      How to DNSPerf on Ubuntu 14.04 with Installation and Quick Start
    • How to Add Different Disclaimers using alterMIME and Postfix based on Domain
      How to Add Different Disclaimers using alterMIME and Postfix based on Domain
    • Blocking Countries on Nginx without the GeoIP Module
      Blocking Countries on Nginx without the GeoIP Module
    • How to Enable Squid Anonymous Stealth Mode
      How to Enable Squid Anonymous Stealth Mode
    • Configuring Suite B, VPN-A and VPN-B in IPSec with Strongswan
      Configuring Suite B, VPN-A and VPN-B in IPSec with Strongswan

    Tags

    apache2 azure azure log analytics blops business centos cheating cissp cloudflare cryptography dns game google gyp internet iphone ipsec isc linux mac marketing microsoft mw2 mx mysql nginx pfsense postfix proxy ps3 qualification radius revision security seo smtp socks squid ssh strongswan tinyproxy ubuntu windows 2012 wordpress xdecrypt.com
    Gyp the Cat dot Com

    Some rights retained Gyp the Cat Dot Com