Skip to main content

The Cheeky Monkey Media Blog

A few words from the apes, monkeys, and various primates that make up the Cheeky Monkey Super Squad.

connect your drupal or wordpress site to Cloudflare

How to connect your drupal or wordpress site to Cloudflare

Looking to increase your website performance and get a free SSL certificate? Check out CloudFlare’s free service to “supercharge” your website.


Cloudflare can increase performance in a few ways. First, it can distribute your content globally usings its content delivery network (CDN). Secondly, it leverages browser caching and can minify HTML, CSS and JavaScript. Depending on your site, you can see some great performance gains, with little work.


Cloudflare can also add an additional layer of security to your site. It can prevent DDoS attacks. It leverages its community of sites and the network learns from every new attack.

It also offers one-click SSL (Secure Socket Layer) which is the standard security technology for establishing an encrypted link between a web server and a browser. SSL is great for security, establishing trust and SEO.

Setup CloudFlare account

Your first step is to create a free account at CloudFlare -

Once your account is setup, you will need to add your first site (you can manage multiple sites from the same account). CloudFlare will then scan your DNS and add the necessary records. Thats awesome, because it saves you from having to copy and paste each record manually.

Once all your DNS records have been added, you will be asked to point your nameservers to to cloudflare. This is needs to be done at your domain registrar (godaddy or other). Once they are switched, the transfer process begins. No one really knows how long this step will take, sometimes it's instant, sometimes it can take up to 24 hours.

Drupal CloudFlare Setup

Once your site has been successfully added to CloudFlare, you should be good to go. However, you may want to download and configure the drupal CloudFlare module (optional). This module corrects a few things drupal related and adds some UI to help block spam and IP addresses.

You will also need to add the following code to the end of your settings.php file:

  1. if (isset($_SERVER['HTTP_CF_CONNECTING_IP'])) {
  3. }

Finally, you need to enter you email and CloudFlare API key into your drupal site at admin/config/people/cloudflare. The API key can be found in your CloudFlare Account tab.

Wordpress CloudFlare Setup

If your sites running on Wordpress, then I would suggest adding the WP CloudFlare plugin. Similar the the drupal module, this corrects a few things related to wordpress and allows you to report spam.

Once you enable the plugin, you will need to add your CloudFlare domain name, API key and Email.

If you're planning on running your site with https, you will want to turn on the protocol rewriting option. What this does is updates all your links from using either "http://" or "https://" to using just "//". This basically tells your browser to load all of these assets using the same protocol as the base page loaded.

Wordpress on HTTPS

If you're planning on running CloudFlare on your wordpress site with HTTPS, you may need to add the following code to the top of your wp-config.php file.

  1. // Settings for https
  2. define('WP_HOME','<a href="'">'</a>);
  3. define('WP_SITEURL','<a href="'">'</a>);
  4. define('FORCE_SSL_ADMIN', true);
  5. define('FORCE_SSL_LOGIN', true);
  6. if ($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')
  7. $_SERVER['HTTPS']='on';

*Note: change to the full path of your website.


These settings correct the site URL to use the https protocol and also forces SSL on the admin and login pages.



If you've made it this far, your site should now be using CloudFlare’s global CDN and performance features. You may also be running your site more securely with HTTPS. To have a look at a site that I setup using CloudFlare, have a look at our WorPress site:

Let us know your thoughts below and if you've seen some noticeable performance gains.

Web Development

Would you like to know more about what we do?

View Our Services

Graphic Design Cheeky Monkey

Have a look at some our client work

View Our Work

Cheeky Monkey Discovery

Learn more about Cheeky Monkey Media

About Us