---
tags:
  - wordpress
  - cdn
  - cloudflare
  - performance
  - security
  - ubuntu
  - dns
---

# Setting Up Cloudflare CDN for WordPress

A Content Delivery Network (CDN) is one of the most impactful upgrades you can make for your website. It sits between your visitors and your Ubuntu server, caching content globally and blocking malicious traffic.

**Cloudflare** is the industry standard, offering a generous free tier that includes global caching, DDoS protection, and free SSL.

## 1. Prerequisites

*   A live WordPress site running on your Ubuntu server.
*   A domain name (e.g., `example.com`) purchased from a registrar (like Namecheap, GoDaddy, or Google Domains).
*   Access to your domain registrar's dashboard.

## 2. Create a Cloudflare Account

1.  Go to Cloudflare.com and sign up.
2.  Click **Add a Site**.
3.  Enter your domain name (e.g., `example.com`) and click **Continue**.
4.  Select the **Free** plan at the bottom and click **Continue**.

## 3. DNS Record Review

Cloudflare will scan your current DNS records.

1.  Review the list. Ensure your **A records** (pointing to your Ubuntu server's IP) and **CNAME records** (like `www`) are present.
2.  Make sure the **Proxy status** toggle is "Proxied" (Orange Cloud) for your root domain and `www`. This means traffic will flow through Cloudflare.
3.  Click **Continue**.

## 4. Update Nameservers

This is the critical step. You must tell the rest of the internet to look at Cloudflare for your domain's information instead of your old registrar.

1.  Cloudflare will show you two nameservers (e.g., `bob.ns.cloudflare.com` and `alice.ns.cloudflare.com`).
2.  **Log in to your Domain Registrar** (where you bought the domain).
3.  Find the **DNS** or **Nameservers** settings.
4.  Change the setting from "Default Nameservers" to "Custom Nameservers".
5.  Paste the two Cloudflare nameservers into the fields.
6.  Save changes at your registrar.
7.  Back in Cloudflare, click **"Done, check nameservers"**.

*Note: This process can take anywhere from a few minutes to 24 hours to propagate globally.*

## 5. Essential Cloudflare Settings for WordPress

Once your site is active on Cloudflare, configure these settings for maximum compatibility and performance.

### SSL/TLS
*   Go to the **SSL/TLS** tab.
*   Set the encryption mode to **Full (Strict)** if you have a Let's Encrypt certificate on your server (recommended).
*   Set it to **Flexible** if you *don't* have an SSL certificate on your server yet (easier, but less secure).

### Speed (Auto Minify)
*   Go to **Speed -> Optimization**.
*   Under **Auto Minify**, check **JavaScript**, **CSS**, and **HTML**. Cloudflare will strip unnecessary whitespace from these files to make them load faster.

### Security
*   Go to **Security -> Settings**.
*   Set **Security Level** to **Medium**.
*   Enable **Bot Fight Mode** to block simple automated attacks.

## 6. The Cloudflare WordPress Plugin

While not strictly required, the official plugin ensures WordPress knows it's behind a CDN.

1.  Log in to your WordPress Dashboard.
2.  Install and activate the **Cloudflare** plugin.
3.  Go to **Settings -> Cloudflare**.
4.  Click **"Sign in here"** (near the bottom).
5.  Enter your Cloudflare email and **Global API Key** (found in your Cloudflare Profile -> API Tokens).
6.  Click **"Apply Recommended Cloudflare Settings for WordPress"**.

## 7. Verification

To confirm traffic is routing through Cloudflare:

1.  Open your website in a browser.
2.  Right-click and select **Inspect** (or F12).
3.  Go to the **Network** tab and reload the page.
4.  Click on your domain name in the list of requests.
5.  Look at the **Response Headers**. You should see `server: cloudflare` and `cf-ray: [some ID]`.

Your site is now faster and protected from attacks.