Skip to main content

What is Cloudflare?

What Cloudflare Does

Cloudflare sits between the internet and your server. When you add a domain to Cloudflare and enable the proxy (the orange cloud), every request to your domain first hits Cloudflare's network before reaching your server.

This gives you, for free on the base plan:

  • Global CDN — static assets cached at 200+ cities
  • DDoS protection — Cloudflare absorbs attacks before they reach you
  • Free SSL — HTTPS for your domain without Certbot
  • DNS management — fast, anycast DNS
  • Firewall rules — block IPs, countries, bots

Adding Your Domain

  1. Create a Cloudflare account
  2. Add your domain (e.g., example.com)
  3. Cloudflare scans your existing DNS records and imports them
  4. Copy the two Cloudflare nameservers (e.g., ava.ns.cloudflare.com)
  5. Go to your domain registrar → change nameservers to Cloudflare's
  6. Wait 0–24 hours for propagation

That's it. Cloudflare is now authoritative for your DNS.

DNS Records in Cloudflare

Cloudflare's DNS interface works like any other. The key difference is the proxy toggle:

RecordProxy StatusEffect
example.com → 1.2.3.4Proxied (orange)Traffic routes through Cloudflare
example.com → 1.2.3.4DNS only (grey)Standard DNS, no Cloudflare features

When proxied, your server's real IP is hidden behind Cloudflare's IPs — an extra layer of protection.

Common records:

Type: A Name: @ Value: <server IP> Proxy: Proxied
Type: A Name: www Value: <server IP> Proxy: Proxied
Type: A Name: api Value: <server IP> Proxy: Proxied
Type: MX Name: @ Value: mail.example.com Priority: 10

Note: @ means the root domain (example.com).

SSL Modes

Cloudflare handles SSL between users and Cloudflare. But what about between Cloudflare and your server? That's controlled by the SSL/TLS mode:

ModeUser → CloudflareCloudflare → ServerUse When
OffHTTP onlyHTTPNever — insecure
FlexibleHTTPSHTTPYour server has no SSL cert (not recommended)
FullHTTPSHTTPSYour server has a self-signed cert
Full (Strict)HTTPSHTTPSYour server has a valid cert (Certbot/ACM)

Use Full (Strict) whenever possible. It encrypts the entire path and validates the cert on your server — avoiding the false security of Flexible mode.

To use Full (Strict), install a cert on your server with Certbot (see the SSL/Certbot section) or use Cloudflare's Origin Certificate (free, only valid for Cloudflare connections).

Cloudflare vs. Route 53 + CloudFront

FeatureCloudflareRoute 53 + CloudFront
CostFree base planRoute 53: $0.50/zone + CloudFront data transfer
Setup speedMinutes30–60 minutes
DDoS protectionIncluded freeAWS Shield Standard (free) on CloudFront
SSLFree, automaticFree via ACM
FirewallGenerous free tierWAF costs extra
Caching controlGoodMore granular per-behavior
Best forGetting started fast, saving costProduction AWS stacks wanting deep integration

Rule of thumb: Cloudflare for simplicity and cost; Route 53 + CloudFront when you're already deep in the AWS ecosystem and need tighter integration (e.g., Lambda@Edge, OAC for private S3).

Page Rules

Page rules let you apply different behavior to different URL patterns:

  • example.com/api/* → Cache Level: Bypass (don't cache API responses)
  • example.com/* → Always Use HTTPS
  • example.com/static/* → Cache Level: Cache Everything, Edge Cache TTL: 1 month

Page rules are ordered — the first matching rule wins.

Firewall Rules

Block malicious traffic without touching your server:

(ip.geoip.country eq "CN") and (http.request.uri.path contains "/admin")
→ Block
(cf.threat_score gt 30)
→ Challenge (show CAPTCHA)

Cloudflare's free plan includes 5 firewall rules.