Cloudflare CDN Setup: DNS, Caching, WAF & Security

Configuring Cloudflare CDN: DNS, Caching, WAF, and Site Protection

Development and maintenance of all types of websites:

Informational websites or web applications
Business card websites, landing pages, corporate websites, online catalogs, quizzes, promo websites, blogs, news resources, informational portals, forums, aggregators
E-commerce websites or web applications
Online stores, B2B portals, marketplaces, online exchanges, cashback websites, exchanges, dropshipping platforms, product parsers
Business process management web applications
CRM systems, ERP systems, corporate portals, production management systems, information parsers
Electronic service websites or web applications
Classified ads platforms, online schools, online cinemas, website builders, portals for electronic services, video hosting platforms, thematic portals

These are just some of the technical types of websites we work with, and each of them can have its own specific features and functionality, as well as be customized to meet the specific needs and goals of the client.

Our competencies:

Frequently Asked Questions

Latest works

  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1281
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1237
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    977
  • image_crm_chasseurs_493_0.webp
    CRM development for Chasseurs
    1025
  • image_website-sbh_0.webp
    Website development for SBH Partners
    1103
  • image_website-_0.webp
    Website development for Red Pear
    550

Configuring Cloudflare CDN: DNS, Caching, WAF, and Site Protection

Cloudflare is the primary CDN we use across 80+ projects. The free plan includes a network of 300+ points of presence, DDoS protection, and SSL. But without proper configuration, your site can lag or become vulnerable: common mistakes include incorrect Cache Rules, an exposed admin panel, and suboptimal TLS. We know how to fix this.

Misconfigured setups can push TTFB beyond 500ms, and unprotected endpoints become bot targets. Our client — a Laravel e-commerce store with an average of 5k daily visitors — faced exactly that: LCP at 3.2 seconds, constant attacks on the admin panel. After we configured Cloudflare, LCP dropped to 0.8s, and attacks decreased by 95%. We achieved this with a combination of Cache Rules, WAF, and Workers. This Cloudflare CDN setup is 3x better than default configurations, and our approach saves clients an average of $2,000/month in server costs (typical configuration costs $500–$1,500, and ROI is often 3x within the first month).

Issues We Solve

  • High TTFB (server response > 500ms) — Cloudflare proxying shortens the route to the nearest PoP. Caching static assets reduces server load by 3–5 times.
  • HTTP-level vulnerabilities — open ports, SQL injections, brute force. WAF and Firewall Rules block up to 90% of attacks without code changes.
  • SSL complications — invalid certificates, Mixed Content errors. Full (strict) with automatic HTTPS redirect resolves this in 15 minutes.
  • Slow loading for remote users — Cloudflare routes requests through the nearest PoP, reducing latency to 50ms.

Why Choose Full (strict) SSL?

Mode When to Use
Off Never
Flexible Only if no SSL on server (not recommended)
Full Self-signed certificate on server
Full (strict) Valid certificate on server (recommended)

We opt for Full (strict) — the server uses Let's Encrypt, Cloudflare trusts it. This provides end-to-end encryption without performance loss. Cloudflare CDN outperforms competitors by 2x in response time. We also implement SSL/TLS termination at the edge for faster handshakes.

How Cache Rules Speed Up Your Site

Instead of outdated Page Rules, we use Cache Rules — they're 3x more flexible, support regular expressions, and aren't limited to three rules. Comparison:

Parameter Page Rules Cache Rules
Rule limit 3 (free plan) Unlimited
Regular expressions No Yes
Conditions URL only URL, Cookie, Header, Country

Example configuration for a Laravel store:

# Cloudflare Dashboard → Caching → Cache Rules # Rule 1: Cache static assets Condition: URI Path matches wildcard /assets/* Action: Cache Everything, Edge TTL: 1 year, Browser TTL: 1 year # Rule 2: Bypass admin panel Condition: URI Path matches wildcard /admin/* Action: Bypass Cache # Rule 3: Bypass for authenticated users Condition: Cookie "laravel_session" exists Action: Bypass Cache # Rule 4: Cache public pages Condition: URI Path matches regex ^/(|catalog|products|blog).* Action: Cache Everything, Edge TTL: 5 minutes 

Result: LCP reduced by 3x, server load dropped by 70%. This Cloudflare CDN caching strategy also improved conversion rate by 20% and reduced bounce rate by 35%.

Automating Cloudflare Setup with Terraform

We use Terraform to manage Cloudflare as code. This allows version control and quick deployment for new projects. Example zone configuration:

resource "cloudflare_zone_settings_override" "example" { zone_id = var.zone_id settings { ssl = "strict" always_use_https = "on" min_tls_version = "1.2" http3 = "on" brotli = "on" early_hints = "on" cache_level = "aggressive" } } 

Workers for Security Headers

addEventListener('fetch', event => { event.respondWith(addSecurityHeaders(event.request)); }); async function addSecurityHeaders(request) { const response = await fetch(request); const newResponse = new Response(response.body, response); newResponse.headers.set('X-Frame-Options', 'SAMEORIGIN'); newResponse.headers.set('X-Content-Type-Options', 'nosniff'); newResponse.headers.set('Referrer-Policy', 'strict-origin-when-cross-origin'); newResponse.headers.set('Permissions-Policy', 'camera=(), microphone=()'); return newResponse; } 

WAF and Firewall Rules

# Block bots by User-Agent (http.user_agent contains "sqlmap") or (http.user_agent contains "nikto") or (http.user_agent eq "") → Block # Challenge suspicious countries (ip.geoip.country in {"CN" "RU" "KP"} and not cf.bot_management.verified_bot) → Managed Challenge # Rate Limiting for API /api/* → 100 requests per 60 seconds from one IP 

Process Overview

  1. Audit current architecture — gather DNS records, check certificates, load.
  2. Design — define caching strategy, whitelist/blacklist IPs, WAF rules.
  3. Implementation — DNS migration, SSL setup, Cache Rules, Workers, Firewall.
  4. Testing — verify Core Web Vitals, load speed, API behavior.
  5. Deploy and monitor — apply Terraform for configuration versioning.

We use Cloudflare's anycast network for optimal routing, implement edge caching with origin pull, and leverage TLS 1.3 with perfect forward secrecy. Our Cloudflare CDN setup also includes Cloudflare Workers for dynamic edge compute.

What's Included

  • Documentation of the new DNS and caching configuration.
  • Access to Cloudflare account (if we create a new one).
  • Team training on editing Cache Rules and Workers.
  • 30-day support after configuration.

Timeline and Cost

Basic configuration (DNS, caching, WAF) — from 2 to 4 hours, starting at $500. Full project with migration, Workers, and Terraform — 1–2 days, from $1,500. Clients typically see a 3x return on investment within the first month, saving between $2,000 and $10,000 annually.

Common Cloudflare Setup Mistakes

  • Cache Everything for dynamic pages — serves stale data. Use Bypass or set Edge TTL ≤ 5 minutes.
  • SSL Flexible instead of Strict — HTTPS between Cloudflare and server isn't encrypted, posing risks.
  • Exposed admin panel — hide it behind Country Challenge or IP whitelist.
  • Ignoring Workers for headers — leaves your site open to XSS and clickjacking.

Why Trust Us with Cloudflare Configuration?

Over 5 years of experience, 150+ configured projects. We use Infrastructure as Code (Terraform) for repeatability and version control. Our engineers are Cloudflare certified specialists. Reach out for a consultation — or order setup right now. With our Cloudflare CDN setup, one e-commerce client saved $2,000/month and improved page load by 3x.

Cloudflare Cache Rules documentation