Home » Web Tutorials » WordPress » How to Setup Cloudflare with WordPress Site?

How to Setup Cloudflare with WordPress Site?

Cloudflare is the most popular content delivery network (CDN) for WordPress sites. The popularity comes due to the fact that many hosting companies offer the basic Cloudflare plan for free. If you are launching your WordPress blog then we recommend you to setup Cloudflare from the beginning to make use of the features. In this article, we will explain how to add WordPress site in Cloudflare account.

Why Cloudflare?

There are many CDN services available for WordPress site. However, basic Cloudflare plan is the best option for beginners.

  • Easy CDN setup without creating special CNAME records
  • Global delivery with connected servers on 100+ countries
  • Free SSL certificate to serve your content through HTTPS
  • Basic protection from bad robots
  • Speedup your website by compressing and minifying files
  • Free plan also allows 3 page rules to customize the caching
  • Get detailed analytics of your traffic
Cloudflare CDN Network
Cloudflare CDN Network

How to Setup Cloudflare?

Almost all shared hosting companies offer basic Cloudflare plan as an additional service. However, we recommend you to manually setup Cloudflare with your WordPress site. For example, SiteGround does not offer Cloudflare due to their own in-house CDN. However, you can add your site directly in Cloudflare and continue using the setup. Also, hosting companies generally need you to use the domain with www. You do not need to have www when setting up the site directly with Cloudflare.

In addition, it will be easy to manage the setup at Cloudflare without logging into your hosting account.  

Cloudflare Account Setup

The first step in manual setup is to create your free Cloudflare account. Go to Cloudflare website and signup for the free basic plan. After signup, login to account using your email and password.

Login to Cloudflare Account
Login to Cloudflare Account

You will see a list of websites previously added under “Home” section. Click on “Add a Site” button to setup Cloudflare for your WordPress.

Add New Site in Cloudflare
Add New Site in Cloudflare

Enter your domain name in the next screen and click on “Add site” button.

Provide Site URL
Provide Site URL

You will see all available pricing plans, scroll down and choose the free plan to continue further.

Select Free Plan
Select Free Plan

Cloudflare will start scanning your site and fetch the current DNS records.

Scanning DNS Records
Scanning DNS Records

All available DNS records on your site will be automatically imported and you can add any missing record manually. Make sure to check all entries are proxied and showing orange cloud icon. If you really do not want any subdomains or subdirectories to exclude from Cloudflare, you can simply click on the proxy status or delete the record.

Check DNS Records
Check DNS Records

After verifying your DNS entries, click on “Continue” to move on to next step. This is a final step to change the nameservers of your domain with Cloudflare’s nameservers.

Nameservers Information
Nameservers Information

You will see the details of your current domain registrar, nameservers and Cloudflare’s servers.

Copy DNS Nameservers
Copy DNS Nameservers

Change DNS of Your Domain

First copy the Cloudflare nameservers and login to your domain registrar account. In this example, we will explain with GoDaddy which may change depending on from who you have purchased your domain. Edit DNS records of your domain and choose to use your own nameservers. Provide the copied Cloudflare servers and save your changes.

Change Nameservers in GoDaddy
Change Nameservers in GoDaddy

In most cases you will see a warning message like below that changing nameservers is risky and you have to provide your consent.

Confirm Nameservers Change
Confirm Nameservers Change

Confirm the changes and make sure your nameservers are changed to Cloudflare’s servers.

Nameservers Changed
Nameservers Changed

Finishing Setup in Cloudflare

Now, head back to Cloudflare and check your nameservers.

Done Nameservers Change
Done Nameservers Change

Generally, the changes will take some time to take effective depending on the site’s traffic. For a new site, DNS changes will be faster and you can check the setup with by clicking on “Check nameservers” button.

Check Nameservers
Check Nameservers

You can submit the check once per hour, though Cloudflare will also scan your site periodically and detect the nameservers.

Check Once Per Hour
Check Once Per Hour

If everything goes fine, you will see a success message that your WordPress site is successfully added in Cloudflare. You will also receive an email with the details indicating the Cloudflare setup with your WordPress site completed.

Setup Finished
Setup Finished

Customizing Cloudflare Options

After adding your site successfully, Cloudflare will take you through 3 steps quick wizard. You can setup important things using the wizard and change the setup later anytime from the dashboard. We recommend you to go through the quick start guide to complete the initial setup by clicking on “Get Started” button.

Cloudflare Optimization Guide
Cloudflare Optimization Guide

Under improve security section, you can enable automatic HTTPS rewrites to fix mixed content warning in browsers. This will help you to always serve site’s content with secured HTTPS protocol.

Enable HTTPS in Cloudflare
Enable HTTPS in Cloudflare

The optimize performance section allows you to enable auto minify for JavaScript, CSS and HTML files. If you are minifying content using caching plugin on your site, then make sure to disable the option at one place.

Auto Minify Settings
Auto Minify Settings

We also recommend to enable Brotli compression to speed up the page loading time.

Enable Brotli Compression
Enable Brotli Compression

Finally, you will see the summary of your selections and click “Finish” button to complete the quick setup.

Finish Settings
Finish Settings

Test Your Site

After completing the setup, you should check the site on the browser to make sure everything is working as expected. You can navigate through various sections in Cloudflare account to use other free options and get detailed analytics. For example, you can go to “Speed” section and test how much is the improvement in page loading speed after setup Cloudflare with your WordPress site. As you can see in the below screenshot, it shows 36% faster after setting up Cloudflare.

Test Speed with Cloudflare
Test Speed with Cloudflare

Removing Cloudflare Setup

Many people do not like to change the DNS nameservers as it will send all traffic through Cloudflare’s servers. However, this has plenty of advantages like completely protecting your site with firewall when you want to upgrade your plan. The other advantage is you can disable Cloudflare anytime by simply changing the DNS on your domain registrar account. After that you can remove the site from Cloudflare to serve pages from your hosting server or from other CDN services.

If you are pausing Cloudflare setup, make sure to use Cloudflare DNS.

Remove Site From Cloudflare
Remove Site From Cloudflare

There is no need to change CNAME records with free account setup. Similarly, you also no need to worry about setting up 301 redirects for your media files which is necessary when you have CNAME zones with providers like StackPath.

Caching Plugins and Cloudflare

Most of the users install caching plugins to speed up their site. However, there are some options overlap with caching and Cloudflare CDN setup. As mentioned above, make sure to enable minification only in one place to avoid breaking your site’s layout. In addition, plugins like W3 Total Cache and WP Rocket offers extension/ add-on for Cloudflare. You can enable the add-on and connect your Cloudflare account. This will allow the plugin to fetch already configured details from your Cloudflare account and optimize properly.  

Leave a Comment

Your email address will not be published. Required fields are marked *