← Course Index

Cloudflare — DNS, CDN & Security

~25 min · Cloudflare

Ref
Primary Source
Cloudflare Learning Center

Cloudflare's own conceptual guides for DNS, CDN, WAF, and DDoS protection. Read →

What Cloudflare Does

Cloudflare sits between the internet and your servers. Its 300+ global edge locations serve cached content locally, block attacks before they reach you, and accelerate everything else. Free tier covers most of what a developer needs.

Setup

  1. Add your site at cloudflare.com → choose Free plan
  2. Cloudflare scans your existing DNS records
  3. Update nameservers at your registrar to Cloudflare's NS
  4. Wait 5–60 minutes for propagation
  5. Verify: dig NS yourapp.com should show Cloudflare NS
⚠️ Orange vs grey cloud

Orange cloud = proxied through Cloudflare CDN + WAF. Grey cloud = DNS only (bypasses Cloudflare). Always orange for your web server A records. Grey for MX, SMTP, direct server access.

SSL/TLS Configuration

Always use Full (Strict) mode — encrypts both Cloudflare↔User and Cloudflare↔Origin.

Enable these in SSL/TLS settings:

Caching Rules

# Cloudflare: Caching → Cache Rules

Rule 1: Cache static assets aggressively
Match: file extension is .css, .js, .png, .jpg, .svg, .woff2
Action: Cache eligible, Edge TTL: 1 year, Browser TTL: 1 year

Rule 2: Never cache API responses
Match: URI path starts with /api/
Action: Bypass cache

Rule 3: Cache HTML for 1 hour
Match: everything else
Action: Edge TTL: 1 hour

WAF Rate Limiting

# Security → WAF → Rate Limiting Rules

Rule: Block aggressive scrapers
Match: all requests
Rate: 100 requests per 1 minute
Action: Block for 1 hour

Rule: Challenge suspicious traffic (score > 30)
# Cloudflare assigns threat scores based on IP reputation
Action: JS Challenge (not a full block — just a proof-of-work)

Check Your Understanding

1. Your Cloudflare DNS record for your web server has a grey cloud. What does this mean?
2. A DDoS attack sends 500,000 requests/minute to your domain. How does Cloudflare help?
3. You have Cloudflare set to "Flexible" SSL. What is the security problem?