Every production SaaS application needs a security and performance layer that sits between the internet and your infrastructure. Cloudflare has become my standard choice for this role because it combines DNS management, CDN delivery, DDoS protection, WAF, bot management, and edge compute into a single platform — at a price point that's accessible to early-stage SaaS applications ($20/month for Pro features).
All five Mavumium platforms run behind Cloudflare. The security configuration has blocked thousands of malicious requests, the CDN reduces origin server load by over 70%, and the DNS propagation speed means domain changes take effect in under 5 minutes rather than the hours typical of other DNS providers.
Cloudflare's Role in the SaaS Stack
Cloudflare sits in front of your entire infrastructure as a reverse proxy. Every request to your domain first hits Cloudflare's edge network, which: checks the request against WAF rules and rate limits, serves cached responses for eligible requests without hitting your origin, applies bot detection and challenge pages for suspicious traffic, optimizes images and assets on-the-fly, and only passes legitimate requests to your actual servers.
This architecture means your origin infrastructure — Vercel, Supabase, or AWS — is shielded from direct internet exposure. Attackers who try to reach your origin directly are blocked at the Cloudflare edge. Users who request already-cached content never touch your origin at all.
DNS Management & Propagation Speed
Cloudflare operates the world's fastest DNS resolver (1.1.1.1) and its authoritative DNS for managed domains propagates globally in under 5 minutes — compared to 24-48 hours for traditional DNS providers. This speed is critical when managing multiple SaaS platforms across different subdomains, where configuration changes need to take effect quickly.
The Mavumium ecosystem DNS structure illustrates a clean multi-subdomain configuration:
# DNS Records for mavumium.com (all proxied through Cloudflare)
Type Name Value Proxy
A mavumium.com 76.76.21.21 (Vercel IP) ✓ Proxied
CNAME connect cname.vercel-dns.com ✓ Proxied
CNAME farming cname.vercel-dns.com ✓ Proxied
CNAME construction cname.vercel-dns.com ✓ Proxied
CNAME scan cname.vercel-dns.com ✓ Proxied
MX @ mail.mavumium.com ✗ DNS Only
TXT @ "v=spf1 include:..." ✗ DNS OnlyAll web-serving records are proxied through Cloudflare (orange cloud), which means Cloudflare's edge IPs are what the world sees — your actual origin IPs are hidden. Email records are DNS-only (grey cloud) since email traffic shouldn't route through Cloudflare's proxy.
Web Application Firewall Configuration
Cloudflare's WAF provides managed rulesets that protect against OWASP Top 10 vulnerabilities — SQL injection, XSS, path traversal, and more — without requiring you to write individual firewall rules. On the Pro plan and above, enabling the Cloudflare Managed Ruleset provides immediate protection against the most common attack vectors.
Beyond managed rulesets, I add custom WAF rules for SaaS-specific protection patterns:
# Custom WAF rule: Block credential stuffing attempts
Rule: Rate limit /api/auth/login to 5 requests per minute per IP
Action: Block for 10 minutes after threshold exceeded
# Custom WAF rule: Protect admin endpoints
Rule: (http.request.uri.path contains "/admin" and
not ip.src in {trusted_ip_ranges})
Action: Challenge (Managed Challenge)
# Custom WAF rule: Block known bad bots
Rule: (cf.client.bot and
not cf.verified_bot_category in {"Search Engine Crawlers"})
Action: BlockThe credential stuffing rule alone has blocked thousands of automated login attempts against Mavumium platforms, protecting user accounts without adding any friction for legitimate users.
DDoS Protection at the Edge
Cloudflare automatically absorbs DDoS attacks at the edge, meaning they never reach your origin infrastructure. The platform handles attacks at network layers 3/4 (volumetric, protocol attacks) and application layer 7 (HTTP floods, slowloris attacks) with automatic detection and mitigation.
For SaaS applications, Layer 7 DDoS protection is the most relevant. Cloudflare's Advanced DDoS Protection detects unusual traffic patterns — sudden spikes in requests to specific API endpoints, unusual geographic distributions, bot-like request timing — and challenges or blocks the traffic before it can impact legitimate users.
Real incident: One of the Mavumium platforms received a Layer 7 HTTP flood targeting the authentication endpoint (12,000 requests/minute from a botnet). Cloudflare detected and blocked it within 45 seconds. The origin Vercel deployment never saw a single request from the attack. Without Cloudflare, this would have caused service disruption and significant Vercel function invocation costs.
Caching Strategy for SaaS
Cloudflare's CDN caches responses at the edge based on Cache-Control headers you set on responses. For SaaS applications, the caching strategy requires careful thought — you want to cache aggressively for public content but ensure authenticated requests always hit your origin.
The cache configuration for Mavumium's public marketing pages:
# Next.js response headers for public pages
Cache-Control: public, max-age=3600, stale-while-revalidate=86400
# For authenticated API responses: never cache
Cache-Control: private, no-cache, no-store
# For static assets (JS, CSS, images): cache forever with hash
Cache-Control: public, max-age=31536000, immutableWith this configuration, Cloudflare serves public marketing pages from edge cache (reducing Vercel function invocations to near zero for marketing traffic), never caches authenticated API responses (ensuring users always get their own data), and caches static assets for a full year (since Vercel appends content hashes to filenames, stale assets are impossible).
Polish: Automatic Image Optimization
Cloudflare's Polish feature automatically converts images to WebP format (or AVIF for supported browsers) and losslessly compresses them at the edge. For images served from AWS S3 or other origins that don't have built-in image optimization, Polish provides a significant bandwidth and performance improvement with zero code changes.
For Mavumium's construction platform, where project photos are served from S3, enabling Polish reduced average image payload by 55% without any changes to the image upload pipeline or serving code.
Cloudflare Workers for Edge Logic
Cloudflare Workers are JavaScript functions that execute at the edge, before requests reach your origin. This capability enables several powerful patterns: A/B testing without origin involvement (the split is handled at the edge), geolocation-based content customization (serving different content based on country), request transformation (adding headers, modifying URLs, handling CORS), and authentication gates (blocking unauthenticated requests at the edge before they hit your API).
Mavumium Cloudflare Configuration
The complete Cloudflare configuration for the Mavumium ecosystem uses: WAF Managed Rulesets enabled for all platforms, SSL/TLS mode set to Full (Strict) with always-redirect to HTTPS, Bot Fight Mode enabled to block credential stuffing, Rate limiting on authentication and API endpoints, Polish and WebP conversion enabled, HTTP/3 (QUIC) enabled for modern browser performance, and Rocket Loader disabled (Next.js manages its own script loading).
Cloudflare is one of the most cost-effective infrastructure investments available to SaaS teams. The $20/month Pro plan provides enterprise-grade DDoS protection, WAF capabilities, and CDN performance that would cost hundreds or thousands of dollars monthly from dedicated security and CDN vendors. For any production SaaS application, Cloudflare between your users and your infrastructure is not optional — it's foundational.