+254725682556 +254725052660 info@ziprof.co.ke
Client Area

DNS - Nameserver

How to Set Up a CDN for Your Website Using Cloudflare

A CDN (content delivery network) caches parts of your website on servers closer to your visitors, so pages load faster and your server handles less traffic. You can add a CDN in front of your site without moving your hosting anywhere: your files and email stay exactly where they are, you just change where your domain's DNS is managed. This guide walks through setting one up with Cloudflare, whose free plan covers what most small business websites need.

What You'll Need Before You Start

  • Access to update your domain's nameservers at wherever you registered the domain.
  • A list of your current DNS records (A, CNAME, MX, TXT) as a backup, in case anything needs to be re-entered manually.
  • About 30 minutes, plus some waiting time for DNS changes to take effect.

Step 1: Create a Cloudflare Account and Add Your Site

  1. Go to Cloudflare's website and sign up for a free account.
  2. Click Add a Site and type in your domain name (without www).
  3. Choose the Free plan and click Continue.

Step 2: Let Cloudflare Scan Your Existing DNS Records

Cloudflare will automatically scan and import your current DNS records. Review the list carefully against your own backup before continuing, since a missed record, especially an MX record for email, can cause mail delivery to stop working.

  1. Check that your website's A record and any CNAME records are present and correct.
  2. Check that your MX records for email are present, and set their status to the grey cloud icon labeled DNS only rather than the orange Proxied icon. Email traffic should never be routed through Cloudflare's proxy.
  3. Add any records that are missing, then click Continue.

Step 3: Point Your Domain's Nameservers to Cloudflare

Cloudflare will give you two nameserver addresses. You need to enter these at your domain registrar, replacing whatever nameservers your domain currently uses.

  1. Log in to your domain registrar's account. This may or may not be the same account as your hosting.
  2. Find the Nameservers or DNS Management section for your domain.
  3. Replace the existing nameservers with the two Cloudflare provided.
  4. Save the change.
Nameserver changes can take anywhere from a few hours to 24-48 hours to fully take effect worldwide. Avoid making other DNS changes during this window. See our guide on how long DNS changes take to propagate for more detail.

Step 4: Turn On the Proxy for the Records You Want Cached

Once Cloudflare confirms your nameservers are active, go back to the DNS tab in your Cloudflare dashboard. For each record you want served through the CDN, typically your website's A and CNAME records but not your MX records, click the cloud icon next to it so it turns orange and reads Proxied. Leave mail-related records on the grey DNS only setting.

Step 5: Set Your SSL/TLS Mode

Since your website already has an SSL certificate through your hosting account, go to the SSL/TLS menu in Cloudflare and set the encryption mode to Full or Full (strict). This tells Cloudflare to keep the connection encrypted all the way to your server rather than falling back to an unencrypted connection.

A Few Things to Keep in Mind

  • Once your nameservers point to Cloudflare, DNS record changes are made in the Cloudflare dashboard, not in your hosting control panel.
  • If you add a new subdomain or email service later, remember to add or update the matching DNS record inside Cloudflare.
  • You can pause Cloudflare at any time from its dashboard, or switch your nameservers back to your original ones, if you decide you no longer want the CDN in front of your site.

If you're not sure whether your site would benefit from a CDN in the first place, see our overview of what a CDN is and when you need one.