The Cheeky Monkey Media Blog

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

Cloudflare banner

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

Performance

Cloudflare can increase performance in a few ways. First, it can distribute your content globally using 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.

Security

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 – https://www.cloudflare.com/a/sign-up

Once your account is set up, 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. That’s 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 Cloudflare. This 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, and 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:

if (isset($_SERVER['HTTP_CF_CONNECTING_IP'])) {
 $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_CF_CONNECTING_IP'];
}

Finally, you need to enter your 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 to 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.

// Settings for https
define('WP_HOME','https://websitename.com');
define('WP_SITEURL','https://websitename.com');
define('FORCE_SSL_ADMIN', true);
define('FORCE_SSL_LOGIN', true);
if ($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')
$_SERVER['HTTPS']='on';

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

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

Conclusion

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 WordPress site: https://cheekymonkey.media

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