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.
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.
Login 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)
Add WordPress site to Cloudflare
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.
Verify DNS records
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.
Free Cloudflare plan
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 links to documentation with different domain registrars on how to change them.
Then click “Continue.”
Change to Cloudflare’s nameservers
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.
Update Cloudflare A name record
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.
Free Cloudflare WordPress 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 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.”
Cloudflare WordPress plugin API credentials
Under the “Home” tab you apply the default settings or update settings as you prefer.
Cloudflare plugin default settings
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.
Cloudflare plugin speed and security settings
Under the “Analytics” tab you can view the number of requests, bandwidth, visitors, and threats on your WordPress site.
Cloudflare plugin analytics
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).
Common flexible SSL error with Cloudflare
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.
Additional Cloudflare Settings
Now that you know how to install Cloudflare, we recommend checking out their first steps documentation, as well as their WordPress suggestions guide. Note: If it mentions mod_cloudflare just be aware that it’s an Apache mod and we don’t run it because we’re using more advanced NGINX web servers. You can also check out how much bandwidth your WordPress site uses vs the CDN.