Going HTTPS with Cloudflare

Having already made my WCG Online project secure (as detailed in a previous post), it’s been on my list for a while to do the same with this website. But I’d heard good things about Cloudflare and wanted to give them a try.

Well I’m glad I did, it was so easy and straight forward. Here’s how it went…

  1. Go to Cloudflare to sign up
  2. Enter your chosen email address and a new password
  3. Add your website domain, so for me this was www.riklewis.com
  4. Click “Scan for DNS” and you’ll get a little video to watch whilst it’s processing
  5. Click “Continue” once it’s down
  6. You’ll then see a list of your DNS records, and which ones Cloudflare are planning to redirect. Make sure this list is correct!
  7. Click “Continue” once you’re happy
  8. You then need to choose a plan – I was just testing so I went with Free website, but this will depend on what your website is used for and what level of service you require
  9. Click “Continue” when you’ve selected
  10. You’ll then see a couple of new name servers – you’ll need to go to your current web hosting platform and change the name servers over to the Cloudflare ones you’ve been given.
  11. Click “Continue” once you’ve done this

That’s it, you’re done. Give it some time for everything to update, and you’ll have an HTTPS version of your site ready to go!

You’ll see a number of different sections within Cloudflare that are available to configure.

Overview

That’s where you should arrive by default. This gives you a summary of the status of your account.

Analytics

Initially there won’t be anything in here, but over time it will start to show the traffic that Cloudflare has handled and how much of your own web hosting bandwidth has been saved by their caching.

DNS

This shows you the DNS records again, and the nameservers, and from here you can make changes if needed, depending on your plan level.

Crypto

This is where the HTTPS magic happens! By default it is set to “Full”, which is good, and will give you the nice green “Secure” message in the address bar (on Chrome, at least). You can also enable HTTP Strict Transport Security (HSTS) and Automatic HTTPS Rewrites, both of which I would definitely recommend to help ensure users find and continue to use the HTTPS version of your website. For HSTS you get some sub-options, including the Maximum Age (max-age) which they recommend 6 months, which sounds about right to me. You can also apply the setting to subdomains, preload (if you wish, but I haven’t) and and the “no-sniff” header (X-Content-Type-Options: nosniff), which I would recommend.

Firewall

This section can be used to try and filter out “bad” traffic. You can do things like rate limit per IP address, and change the challenge page settings, which is where a user gets sent if they are determined as “bad”, so they get a chance to prove themselves to actually be “good”. I left all of this as default.

Speed

Here you get the option to do things to speed up your website, such as minifying (I selected Javascript, CSS and HTML). A lot of these options require a paid plan, but it’s worth having a look and seeing what works for you.

Caching

You can set a few different cache options in here, but there are also a couple of really important buttons in here.

  1. Development Mode – if you are in the process of making and testing changes to your website, you’re going to want to enable this, so that the cache is bypassed.
  2. Purge Cache – once you’ve made the change to your website, you’re going to want to then purge the Cloudflare cache, to ensure the changes come through, before you disable the Development Mode.

Page Rules

This allows you to change certain settings for different pages, so you can make exceptions. I’ve not set any of these, but I think this could prove really useful moving forwards!

Network

Here you can make certain network decisions, such as whether web sockets should be able to link to your original server, and IPv4 vs. IPv6, etc..

Traffic

Here you can control and manage your traffic, as well as seeing any firewall events that have been triggered.

Customize

This allows you to change certain error messages (such as HTTP 429 – Too Many Requests), but none of the options here are available on the free plan.

Apps

You can enable extra functionality here, including…

  • A Better Browser – warns users if their browser is old
  • Google Analytics
  • Google Webmaster Tools
  • Infolinks – monetize your site with ads
  • New Relic Browser – provides insight into the experience your site users are having
  • OpenDyslexic – overrides site fonts with OpenDyslexic
  • Trumpet – lets you put a dismissable message at the top of your site
  • VigLink – helps you earn money from your site’s outbound links automatically

Scrape Shield

Cloudflare can scrape your content in order to make certain changes, to help protect you. For example, it can obfuscate email address, and prevent hotlinking.

 

And that’s it, all done! You’re ready to go, and they’ve done all the hard work for you. There’s also an API for all of these settings, so you can make changes automatically if you want to. However, I’ve not looked at this side of things yet.

So now I can run my newly secure website through securityheaders.io and see how I’m doing. And I get an A!

The only reason that I don’t get an A+ is that I’m missing is HTTP Public Key Pinning (HPKP). This is generally a good thing to do, but can cause problems when using Cloudflare as you’re never sure when they’re going to update the certificates. They’ve suggested waiting until they implement this natively, so I’m going to go with that advice. To be honest, I don’t have a login page or any e-commerce, so no one’s going to gain anything by doing a rather complicated attack on my certificates, so there’s no risk here for me.

From my experience, I can certainly recommend Cloudflare to anyone, especially if they’re looking to make their website secure.