Cloudflare is a company that provides content delivery network (CDN), DNS, DDoS protection, and security services. They have become very well known in the web performance industry for fast DNS lookup times and have a robust network of over 100 different data centers around the globe. They are backed by some of the biggest names in the industry such as Google, Microsoft, and Qualcomm. Some of their clients include Nasdaq, Digital Ocean, Zendesk, and Cisco.
If you are looking for an easy way to speed up and enhance the security on your WordPress site, Cloudflare is a great solution. Most customers can even utilize their free plan, which offers unlimited CDN bandwidth. Follow the steps below on how to install Cloudflare on your WordPress site. It works great with Kinsta and in fact, we even recommend it to a lot of our customers.
Note: if you use Cloudflare, you can’t use our premium DNS from Amazon Route 53. Cloudflare operates as a full proxy service, which means you have to choose one or the other. If you want to use our premium DNS, you can use an alternative CDN to speed up your site, such as KeyCDN, which isn’t a full proxy.
- Install Cloudflare
- Common Cloudflare Problems
- How to Clear Cloudflare Cache
- Additional Cloudflare Settings
This tutorial assumes you already have a Cloudflare account. If you don’t, you can visit the Cloudflare website and signup for a free account.
Log in to the Cloudflare dashboard and click on “+ Add Site.” Input your WordPress site’s domain and click on “Begin Scan.” (You don’t need to add www or HTTP/HTTPS, the root domain is fine)
It may take a minute or two and then click on “Continue Setup.”
Cloudflare gives you two options. You can use their CDN and protection (which accelerates and protects your sites) or you can simply use their DNS. Most customers will want the former, as this is where you will benefit from everything Cloudflare has to offer. To ensure that your domains are enabled, make sure the cloud is lit up as orange. If you have additional records, such as email (MX records), these should be off Cloudflare (grey). Click on continue after you have verified everything. You can always modify these records later on.
On the next page, you will need to select a Cloudflare plan. We recommend starting with the free plan, which works for most users. Then click “Continue.” You can read more about the differences in Cloudflare’s plans.
You will then need to change the nameservers on your domain to point to Cloudflare (use the ones they provide). Because Cloudflare is a full proxy service, basically how it works is you point your domain to Cloudflare, and Cloudflare then points your domain to Kinsta. There is no downtime when you switch your nameservers. Here are a couple of links to documentation with different domain registrars on how to change them.
- How to change nameservers with Namecheap
- How to change nameservers with GoDaddy
- How to change nameservers with Google Domains (suggested reading: Google Domain Reviews [Pros vs Cons])
- How to change nameservers with Bluehost
Then click “Continue.”
This shouldn’t take very long, but allow up to 24 hours for this change to be processed.
If your site wasn’t already pointed at Kinsta, or you were using Kinsta’s premium DNS, you will need to update the A record to point to Kinsta within the Cloudflare dashboard. Click into “DNS” and next to the A name record, change it to your Kinsta IPv4 address. The IPv4 address of your WordPress site can be found on in your MyKinsta dashboard under your sites “Info” tab. If you aren’t a Kinsta customer, simply make sure you update it with the IP address provided to you by your WordPress host.
And that’s it! Your WordPress site now has Cloudflare installed.
Step 6 (Optional)
There is an additional step for WordPress users which we do recommend. It is not required, but certain things with Cloudflare might not function properly if you don’t install the official Cloudflare plugin.
You can download it from the WordPress repository or by searching for it within your WordPress dashboard under “Add New” plugins. It features the following:
- Fix for WordPress comments appearing from the same IP address
- Automatic cache purging
- Header rewrite to prevent a redirect loop when Cloudflare’s Universal SSL is enabled
- Ability to change settings on Cloudflare account from within the plugin itself (cache purge, security level, image optimization, etc.)
- View analytics such as total visitors, bandwidth saved, and threats blocked
- Support for HTTP2/Server Push
After you install the plugin you will need to input your Cloudflare email address and API key in the settings. You can grab your API key here. Copy the one that says “Global API Key.” Then click on “Save API Credentials.”
Under the “Home” tab you apply the default settings or update settings as you prefer.
Under the “Settings” tab you can enable image optimization if you are on a pro plan, turn on development mode, change the security level, and enable automatic HTTPS rewrites.
Under the “Analytics” tab you can view the number of requests, bandwidth, visitors, and threats on your WordPress site.
Common Cloudflare Problems
A very common error that users get when trying to install Cloudflare on their WordPress site is “ERR_TOO_MANY_REDIRECTS” in Chrome or “The page isn’t redirecting properly” (Firefox).
This is due to having SSL setup on your web server already and then having Flexible SSL enabled with Cloudflare. If you have an SSL certificate with your web host (Kinsta) already, then you will want to switch the SSL mode to full.
Otherwise, you can create a page rule to fix this issue.
How to Clear Cloudflare Cache
Running into problems? There will be times when you need to clear (purge) Cloudflare cache. There are two easy ways to do this.
Option 1 – Clear Cloudflare Cache in WordPress Plugin
If you have the Cloudflare WordPress plugin installed, you can purge the cache from “Settings → Cloudflare.”
Option 2 – Clear Cloudflare Cache from Control Panel
Your other option is to clear Cloudflare cache from their control panel. To do so, click into the “Caching” tab and then on “Purge Everything.”
Once you have everything up and running smoothly, it’s better to only purge the cache of individual files. Cloudflare provides an easy way to do this.
Note: If you purge everything, you may temporarily degrade performance on your website as assets have to re-cache. However, sometimes this is unavoidable, especially if you aren’t sure exactly what script or asset on your site needs to be refreshed.
Additional Cloudflare Settings
Now that you know how to install Cloudflare, we recommend checking out our detailed post on the best settings for WordPress users. You can also check out how much bandwidth your WordPress site uses vs the CDN.
If you enjoyed this tutorial, then you’ll love our support. All Kinsta’s hosting plans include 24/7 support from our veteran WordPress developers and engineers. Chat with the same team that backs our Fortune 500 clients. Check out our plans