Why Cloudflare?
- Fast global DNS network (one of the fastest resolvers)
- Free CDN and DDoS protection
- Free SSL certificates
- Easy DNS management interface
Setup
- Create a free Cloudflare account
- Add your domain — Cloudflare scans existing DNS records
- Review imported records and fix any missing ones
- Update nameservers at your registrar to the Cloudflare ones provided
Proxy vs DNS Only
- Proxied (orange cloud) — traffic goes through Cloudflare. Enables CDN, SSL, DDoS protection. Hides your server IP.
- DNS Only (gray cloud) — Cloudflare only provides DNS resolution. Traffic goes directly to your server.
When to Use DNS Only
- Email records (MX, SPF) — always DNS Only
- SSH access — if using direct IP anyway
- Non-HTTP services (game servers, databases)
Page Rules
- Force HTTPS:
*.example.com/* → Always Use HTTPS - Cache everything:
example.com/static/* → Cache Level: Cache Everything
API Access
# Update DNS record via API
curl -X PUT "https://api.cloudflare.com/client/v4/zones/ZONE_ID/dns_records/RECORD_ID" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
--data '{"type":"A","name":"example.com","content":"198.51.100.10","ttl":300}'