Back to website

Setting Up Cloudflare for WordPress for Free

Cloudflare makes your WordPress site faster and more secure with a global CDN, automatic HTTPS, and basic security—all for free. This guide will walk you through all the steps from creating an account to optimal WordPress integration, without requiring technical expertise.

1. Create an Account

  • Go to Cloudflare Account Creation and register with your email and a strong password.
  • Confirm your email via the verification link.
  • Log in to the Cloudflare Dashboard.

2. Add Your Domain

  • In the dashboard, click “Add a site” and enter your domain (e.g., yourdomain.com).
  • Choose the “Free” plan and continue.
  • Cloudflare will scan your DNS records. Verify that these are present:
    • A or CNAME for @ (root) and www.
    • MX, SPF (TXT), DKIM (TXT), DMARC (TXT) for email.
  • Click “Continue”.
  • Simply explained: DNS are “signposts” that indicate where your site and email are located.

3. Change Nameservers at Your Registrar

  • Cloudflare will display 2 nameservers (e.g., lara.ns.cloudflare.com and hugh.ns.cloudflare.com).
  • Log in to your domain registrar (TransIP, Neostrada, Namecheap, GoDaddy, etc.).
  • Go to domain settings > Nameservers > choose “Custom nameservers”.
  • Replace the current nameservers with Cloudflare’s and save.
  • Go back to Cloudflare and click “Done, check nameservers”.

Important:

  • It may take some time for the change to propagate everywhere: usually within an hour, but sometimes up to 1 to 2 days.
  • You will receive an email once your domain is active in Cloudflare.

4. Set Up SSL/HTTPS

  • Go to SSL/TLS > Overview.
  • Preferably choose:
    • Full (Strict): best option, requires a valid certificate on your server (or a Cloudflare Origin Certificate).
    • Full: use this if Strict is not yet possible.
    • Only use Flexible if your server does not support HTTPS (not recommended).
  • Go to SSL/TLS > Edge Certificates and enable:
    • Always Use HTTPS: On (forces HTTPS).
    • Automatic HTTPS Rewrites: On (resolves mixed content issues).
  • Set “Minimum TLS Version” to 1.2 for modern security.
  • Tip: Only activate HSTS when everything is 100% working via HTTPS, as HSTS enforces strictly.

5. Speed Optimization and Caching

  • Go to Speed > Optimization.
    • Auto Minify: Enable HTML, CSS, JavaScript.
    • Brotli: On.
  • Go to Caching:
    • Caching Level: Standard.
    • Browser Cache TTL: 4 hours to 1 day is fine for most sites.
    • Purge Cache: use this after major updates or design changes.
  • Use “Development Mode” to temporarily disable caching during live debugging (automatically active for 3 hours).
  • Note: Test your site after each change, as some optimizations may conflict with certain themes/plugins.

6. DNS Proxy (Orange or Gray)

  • Orange cloud = via Cloudflare proxy (CDN + security). Use for web traffic: @ (root) and www.
  • Gray cloud = DNS only, no proxy. Use for email and systems:
    • MX, SPF (TXT), DKIM (TXT), DMARC (TXT) should always remain gray.
    • Subdomains for mail, ftp, sftp, smtp are usually gray.
  • Rule of thumb: website = orange; email/infra = gray.

7. Enable Security

  • Security > WAF:
    • Enable the free Managed Rules (protection against common attacks).
  • Security > Bots:
    • Bot Fight Mode: On (basic protection).
    • Optional: create a rule for your login page (e.g., WordPress wp-login.php):
      • Security > WAF > Firewall rules > Create rule:
        • Expression: URI Path contains /wp-login.php
        • Action: Managed Challenge
  • Test your site after enabling to prevent false positives.

8. WordPress Integration with Cloudflare

8.1 Setting Up the Cloudflare Plugin (Recommended)

Goal: Automatic cache purging upon updates, managing basic settings, and a secure connection to your Cloudflare account.

  • Install:
    • WordPress > Plugins > Add New > search for “Cloudflare” (author: Cloudflare, Inc.) > Install and Activate.
  • Connect:
    • Go to Settings > Cloudflare or Tools > Cloudflare.
    • Log in with your Cloudflare account and authorize, or choose manually:
      • Email of your Cloudflare account.
      • API Token (recommended) with scopes: Zone.Zone, Zone.Cache Purge, Zone.Settings (only for your zone).
        • Create: Cloudflare Dashboard > My Profile > API Tokens > Create Token > custom scopes and restrict to your domain.
      • Zone ID (Dashboard > your domain > right sidebar).
  • Basic Use:
    • Development Mode: only temporarily for live adjustments, then disable.
    • Purge Cache:
      • “Purge Everything” after theme/plugin updates or major content changes.
      • “Purge by URL” for targeted changes (a single page or post).
  • Recommended:
    • In the Cloudflare Dashboard (Speed > Optimization), use Auto Minify and Brotli; avoid double minification in other plugins.
    • “Apply Recommended Cloudflare Settings” (if present) can be useful; check your site after applying.
  • Test:
    • Update a page/post, clear WordPress cache (if active), and verify that Cloudflare purge occurs. First hit: cf-cache-status: MISS, then HIT.
  • Tip: Always choose a restricted API Token instead of the Global API Key for better security.

8.2 Integration via FlyingPress

Goal: Align FlyingPress and Cloudflare cache for consistent performance.

  • Requirements:
    • FlyingPress active and basic cache configured.
    • Cloudflare active on your domain.
  • Connect:
    • WordPress > FlyingPress > Integrations (or Cloudflare/CDN tab).
    • Activate Cloudflare and fill in:
      • API Token (scopes: Zone.Cache Purge, Zone.Zone, Zone.Settings).
      • Zone ID (and Account ID if requested).
    • Save.
  • Recommendations:
    • Enable “Purge Cloudflare cache on update”.
    • Let FlyingPress handle minify/defer/concatenate and keep Cloudflare for Brotli + Auto Minify if desired (do not optimize twice).
    • Disable Cloudflare Rocket Loader if you experience script issues.
    • Set exclusions for dynamic pages (shopping cart/checkout/account for WooCommerce).
  • Test:
    • Publish/edit a post and check if a purge is triggered.

8.3 Integration via WP Rocket

Goal: WP Rocket allows cache purging and optimizations to work together with Cloudflare.

  • Requirements:
    • WP Rocket active and basic cache configured.
    • Cloudflare active on your domain.
  • Connect:
    • Settings > WP Rocket > Add-ons or CDN.
    • Activate the Cloudflare add-on.
    • Fill in:
      • Email (Cloudflare account).
      • API Token (scopes: Zone.Zone, Zone.Cache Purge, Zone.Settings).
      • Zone ID.
    • Save.
  • Recommendations:
    • Enable “Purge Cloudflare on Post/Page Update”.
    • Let WP Rocket or Cloudflare handle minify/combining; avoid duplicate optimization.
    • Use LazyLoad and WebP via WP Rocket or your media plugin (not twice).
    • Leave Cloudflare Rocket Loader off if you already use defer/async in Rocket.
  • Test:
    • Edit content, click “Clear Cache” in WP Rocket, and check for purge in Cloudflare.

9. Check and Troubleshooting

  • Wait for nameserver activation (Cloudflare sends a confirmation).
  • Visit your site via https:// and check for the padlock icon.
  • In Cloudflare > DNS, check that web records are orange and email records are gray.
  • Test speed after 24 hours (CDN cache needs to “warm up”).

Common Problems:

  • Site offline after enabling:
    • Check if A/CNAME points to the correct server IP.
    • Temporarily disable the orange cloud (gray) to test if the proxy is the cause.
  • “Not secure” or mixed content:
    • Enable “Always Use HTTPS” and “Automatic HTTPS Rewrites”.
    • Adjust hard-coded http links in themes/widgets.
  • Email not working:
    • MX, SPF, DKIM, DMARC must be present and gray (DNS-only).
    • Never try to proxy email records.
On this page

Check our framework demo

Here goes your text … Select any part of your text to access the formatting toolbar.

Demo - Blog Framework
Apply