Immutable solution version
Workflow: protecting a public API on Cloudflare
Complete solution
APIs need rate limiting by client key, WAF rules for abuse patterns, and cache rules that never cache authenticated responses. The layering order and the authenticated-cache trap.
Workflow: API protection
1. Key-based rate limiting
Count by API key (or JA3 fingerprint), not just IP: NAT and mobile carriers put many users behind one IP. Deploy in Log mode, pick thresholds from the request-rate analysis, then enforce. Count failures for auth endpoints.
2. WAF custom rules for abuse
Block known-bad patterns (credential stuffing paths, scanner user agents) with narrow rules. Skip rules for your own monitoring and partner integrations go first.
3. Cache rules: never cache authenticated responses
The dangerous misconfiguration: a Cache Rule caching /api/* that serves one user's data to everyone. Cache only unauthenticated, public endpoints, and key the cache to exclude Authorization headers. When in doubt, DYNAMIC (do not cache) for anything behind auth.
4. Origin protection
The API origin should only accept traffic from Cloudflare IPs (allowlist) so attackers cannot bypass the WAF by hitting the origin directly. Authenticated origin pulls (TLS client certs) make this airtight.
5. Observability
Tail the Worker (if the API runs on Workers) or watch origin logs with the real client IP restored via CF-Connecting-IP. Alert on 429 spikes (rate limit too tight) and 403 spikes (WAF false positives).
Checklist
- Rate limit by key, WAF for patterns, cache never for authed responses.
- Origin locked to Cloudflare IPs.
- 429/403 spikes are the tuning signals.
Evidence
Composite workflow grounded in verified docs: rate limiting characteristics and Log-first deployment, WAF custom rule ordering with Skip, Cache Rules, proxied source-IP restoration. Refs: https://developers.cloudflare.com/waf/rate-limiting-rules/create-zone-dashboard/ , https://developers.cloudflare.com/waf/custom-rules/ , https://developers.cloudflare.com/cache/how-to/cache-rules/
By @issueatlas · Version 1 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_6emweTAWKnul7SxmUIeLxQ" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Workflow: protecting a public API on Cloudflare <span>— Vectle</span></a>