Cloudflare
Global network delivering content delivery, security, and performance services. Cloudflare is essential infrastructure for modern web applications, offering free and paid tiers.
Core Services
CDN (Content Delivery Network)
- Global Network: 300+ data centers worldwide
- Automatic Caching: Static content cached at edge
- Cache Control: Flexible cache rules and purging
- Image Optimization: Polish and Mirage for images
- HTTP/3 & QUIC: Latest protocols enabled
DNS
- Authoritative DNS: Ultra-fast DNS resolution
- Free DNS: Managed DNS for any domain
- DNSSEC: Security extensions enabled
- DNS Analytics: Query insights and analytics
- 1.1.1.1: Public DNS resolver (privacy-focused)
Security
- DDoS Protection: Unlimited DDoS mitigation on all plans
- WAF (Web Application Firewall): Protection against OWASP Top 10
- SSL/TLS: Free SSL certificates with auto-renewal
- Bot Management: Detect and mitigate malicious bots
- Rate Limiting: Protect against API abuse
- Zero Trust: Network access control and ZTNA
Performance
- Argo Smart Routing: Optimize routing for 30% faster
- Load Balancing: Global and health-checked load balancing
- Workers: Serverless functions at the edge
- Pages: JAMstack deployment platform
- R2: S3-compatible object storage (no egress fees)
- KV: Key-value storage at the edge
Cloudflare Workers
Run JavaScript at the edge:
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
async function handleRequest(request) {
// Your logic here
return new Response('Hello from the edge!', {
headers: { 'content-type': 'text/plain' },
})
}
Use Cases
- API gateways
- A/B testing
- Geo-routing
- Authentication
- HTML rewriting
- Caching logic
Cloudflare Pages
Deploy JAMstack sites:
# Deploy with Wrangler CLI
npx wrangler pages publish dist
# Or connect Git repo for auto-deployment
# Supports: Next.js, React, Vue, Svelte, Hugo, etc.
Features:
- Unlimited bandwidth on free plan
- Automatic deployments from Git
- Preview deployments for PRs
- Custom domains with SSL
- Edge functions via Workers
Cloudflare R2
S3-compatible storage without egress fees:
// Upload to R2
await env.MY_BUCKET.put('file.txt', 'content')
// Read from R2
const object = await env.MY_BUCKET.get('file.txt')
const text = await object.text()
Pricing
Free Plan
- Unlimited DDoS mitigation
- Global CDN
- Free SSL certificates
- Shared SSL
- 100k Workers requests/day
- Unlimited Pages bandwidth
Pro ($20/month)
- Everything in Free
- WAF
- Image optimization
- 10M Workers requests/month
- Mobile optimization
- 20 custom page rules
Business ($200/month)
- Everything in Pro
- Custom SSL certificates
- Advanced DDoS
- PCI compliance
- 100M Workers requests/month
- Priority support
Enterprise (Custom)
- Everything in Business
- 24/7/365 phone support
- Guaranteed uptime SLA
- Advanced security features
- Dedicated solutions engineer
Common Configurations
DNS Setup
- Add domain to Cloudflare
- Update nameservers at registrar
- Configure DNS records
- Enable proxy (orange cloud) for protection
SSL/TLS Modes
- Flexible: Client↔CF encrypted, CF↔Origin unencrypted
- Full: Encrypted end-to-end (self-signed OK)
- Full (Strict): Encrypted with valid certificate
- Strict (Custom): Custom certificate validation
Page Rules
URL Pattern: example.com/api/*
Settings:
- Cache Level: Bypass
- Security Level: High
- Rate Limit: 100 req/min
Security Features
Firewall Rules
(http.request.uri.path contains "/admin" and ip.src ne 1.2.3.4)
Transform Rules
Modify headers, URLs, or responses at the edge.
Rate Limiting
// Block if > 100 requests/minute from single IP
if (rate > 100/60s) {
return new Response('Rate limited', { status: 429 })
}
Analytics
- Traffic analytics
- Security insights
- Performance metrics
- Worker analytics
- DNS analytics
- Real-time threat monitoring
Best For
- Startups: Free plan great for getting started
- SaaS Products: DDoS protection and global CDN
- APIs: Workers for edge computing
- Static Sites: Pages for JAMstack deployment
- Security-Conscious: WAF and DDoS protection
- Global Applications: Worldwide presence needed
Integration
Terraform
resource "cloudflare_zone" "example" {
zone = "example.com"
}
resource "cloudflare_record" "www" {
zone_id = cloudflare_zone.example.id
name = "www"
value = "192.0.2.1"
type = "A"
proxied = true
}
API
curl -X GET "https://api.cloudflare.com/client/v4/zones" \
-H "Authorization: Bearer YOUR_API_TOKEN"
Pro Tips
- Always use "Full (Strict)" SSL mode in production
- Enable "Always Use HTTPS" in SSL/TLS settings
- Use Page Rules strategically (limited on free plan)
- Workers can replace many backend services
- R2 saves massive costs vs S3 for high-bandwidth use
- Cache everything possible with proper cache headers
- Use Transform Rules instead of Workers when possible
- Enable DNSSEC for additional security
Cloudflare has become essential infrastructure for the modern web, offering enterprise-grade security and performance with a generous free tier that's perfect for indie developers and startups.
Ready to get started? Visit the official site to learn more.
Visit official site north_east