Cloudflare
Setting Up Cloudflare with Your Power Down Server
Add Cloudflare's CDN, WAF, and DDoS protection in front of your website — the free tier covers most use cases.
Published Apr 25, 2025Updated Jun 1, 20269 min readBeginner
Table of Contents
Why Use Cloudflare?
Cloudflare acts as a reverse proxy between visitors and your server, providing free CDN caching, DDoS protection, WAF, SSL, and detailed analytics — without any code changes to your application.
Step 1: Create a Cloudflare Account and Add Your Site
- Go to cloudflare.com and create a free account
- Click Add a Site and enter your domain
- Select the Free plan
- Cloudflare scans and imports your existing DNS records
- Review the imported records — verify A records point to your server IP
Step 2: Update Nameservers at Your Registrar
Cloudflare gives you two nameservers like:
ns1.cloudflare.com
ns2.cloudflare.com
Log in to your domain registrar and replace the existing nameservers with these. Propagation takes 24–48 hours, often much less.
Step 3: Understand the Orange vs Gray Cloud
- Orange cloud (proxied): Traffic routes through Cloudflare — CDN, DDoS protection, and WAF apply
- Gray cloud (DNS only): Cloudflare just resolves DNS, traffic goes directly to your server
Enable the orange cloud for your main A records (www, @). Keep MX records gray — email should never be proxied.
Recommended Security Settings
| Setting | Where | Recommended Value |
|---|---|---|
| SSL/TLS Mode | SSL/TLS → Overview | Full (Strict) — requires valid cert on server |
| Always HTTPS | SSL/TLS → Edge Certificates | On |
| HSTS | SSL/TLS → Edge Certificates | Enable (max-age: 6 months) |
| Security Level | Security → Settings | Medium |
| Bot Fight Mode | Security → Bots | On |
| Browser Integrity Check | Security → Settings | On |
Caching Static Assets
Go to Caching → Configuration:
- Set Browser Cache TTL to 1 month for static sites
- Enable Always Online to serve cached pages if your server is down
Purge Cache After Deployment
# Using Cloudflare API
curl -X POST "https://api.cloudflare.com/client/v4/zones/ZONE_ID/purge_cache" -H "Authorization: Bearer YOUR_API_TOKEN" -H "Content-Type: application/json" --data '{"purge_everything":true}'CloudflareCDNDDoSDNSsecurity
Was this article helpful?
