This post discusses how to get the most our of Cloudflare. Cloudflare is a caching service, hosted DNS provider, and a CDN that purports to offer increased website security and speed.
Those who have used the free service either hate it or love it. But, regardless of your opinion, there are two issues you need to be aware of if you opt to use them: disabling Cloudflare on wp-admin pages and restoring web visitor IP addresses for tracking within in Google Analytics as well as within your own server logs
Some Thoughts on Hosted DNS: Go With Hosted DNS If You’re Serious About Site Speed
Most registrars (specially gandi.net) are awfully slow if you’re using their name servers. SolveDNS tests the major registrars and dedicated DNS providers monthly. The speed difference is an order of magnitude between the fastest and slowest providers. Your best bet is to go with Verizon, Microsoft (Azure), or Cloudflare. As of March 27, 2015, these three amigos rank in the top 5 quite consistently in SolveDNS’ tests.
Disabling Cloudflare on
Besides being a DNS hoster, CloudFlare is also a site accelerator, security monitoring and caching service. CloudFlare offers great tips for new users. However, CloudFlare’s caching features may interfere with your access to WordPress’
wp-admin. Here’s how to fix this issue:
Create a CloudFlare PageRule by defining the following rule:
Then toggle Apps and Performance to “off” then click the Add Rule button. As soon as the rule is in place, your WordPress admin pages will not have CloudFlare Apps like UserVoice included and will not be altered by features like Rocket Loader or AutoMinify.
How to Restore Visitor IP Addresses In Server Logs And Within Google Analytics When Using CloudFlare
If you’re using IP filters on your Apache install, CloudFlare will break these filters since it works as a proxy to your web server. Also, for the same reason, CloudFlare will by default render your Google Analytics code useless.
To restore IP addresses you will need to install mod_cloudflare. However, mod_cloudflare has a few software dependencies that need to be installed first:
$ apt-get install libtool apache2-dev
Next, you should download the mod_cloudflare source to your server:
# wget https://www.cloudflare.com/static/misc/mod_cloudflare/mod_cloudflare.c
Finally, install the module. Depending on your system, the command to run might be apxs or apxs2. So, run one of the below two commands. If you get a “Command not found” when running one, try the other:
$ apxs -a -i -c mod_cloudflare.c
$ apxs2 -a -i -c mod_cloudflare.cReference: Logging Real Visitor IP Addresses: mod_cloudflare for Apache (Option 4: Manual Installation: Debian / Ubuntu)
In the event you decide Cloudflare is not for you, this post explains how to remove and uninstall
For Ubuntu and Debian builds you can stop mod_cloudflare from loading by renaming, deleting, or moving (or alternatively commenting-out the mod_cloudflare load directive within) the config file located at:
Here’s whats added to your system when you install mod_cloudflare:
- Raw dump of mod_cloudflare files downloaded with wget: /home/your_username/
- Configuration file: /etc/apache2/mods-available/cloudflare.load
- Actual executable called by the above config File: /usr/lib/apache2/modules/mod_cloudflare.so