Use mod_cloudflare on your Ubuntu 10.04 LTS LAMP server

Written by Steve Nims on . Posted in Blog Posts

So I was poking around with the streamlineyourself.com LAMP server today and noticed on the CloudFlare-Tools github page that the apache module used to replace the remote_ip variable in my server’s logs with the correct remote_ip sent from CloudFlare was updated. I also noticed I had completely forgotten how to pull the branch from their repository to my server and install it (lets just say it’s been a while). Actually, I can pinpoint the last time I played around with these files to a CloudFlare support desk conversation I had with CF’s own “Ian” this past August. I’m glad I stumbled upon it because I clearly had no clue what to do anymore…and here are the steps I took, reposted for you to read…

1.) In my home directory on my server, I created a directory to save the pull from the Cloud Flare git repository, initialized an empty local git repository, added the remote, and pulled the master branch to my directory:

cd ~/
mkdir mod_cloudflare.c
cd mod_cloudflare.c
sudo git init
sudo git remote add origin http://github.com/cloudflare/CloudFlare-Tools.git
sudo git pull origin master

2.) After git downloaded the files from the repository, I ran the following apxs2 command:

sudo apxs2 -c mod_cloudflare.c

-This creates the .libs directory where the compiled module is located

3.) Next I copied the mod_cloudflare.so file from the .libs directory to the location apache stores modules and changed permissions on the file:

cd .libs
sudo cp mod_cloudflare.so /usr/lib/apache2/modules/
sudo chmod 644 /usr/lib/apache2/modules/mod_cloudflare.so

4.) I wanted to be able to use the a2enmod/a2dismod commands so I created a file in /etc/apache2/mods-available named “cloud_flare” with the following text inside said file:

LoadModule cloudflare_module /usr/lib/apache2/modules/mod_cloudflare.so

5.) I enabled the module and restarted apache:

sudo a2enmod cloud_flare
sudo /etc/init.d/apache2 restart

Now, back to watching episodes of Spartacus!

Tags: , , , , , ,

Trackback from your site.

Leave a comment

You must be logged in to post a comment.