How to Configure Cloudflare WAF Rate Limiting Rules to Protect Login Endpoints
Login pages like /wp-login.php, /xmlrpc.php, /user/login, and /api/auth/login attract constant automated credential-stuffing traffic. Even when passwords are strong, thousands of POST requests per minute force your origin web server and database to hash passwords repeatedly, driving CPU to 100% and slowing down real visitors. Using Cloudflare WAF Rate Limiting rules, you can absorb those bursts at the edge before they ever touch PHP or your application workers.
Editorial illustration: start with a Managed Challenge on small bursts, then block sustained abuse at the edge.
Summary
- Per Cloudflare’s WAF Rate Limiting documentation and CMS security guide, rate limiting rules stop brute-force and credential-stuffing traffic at the edge before it consumes origin PHP/database resources.
- Filter specifically on
POSTrequests to login paths (rather thanGETrequests) so normal page views, redirects, and asset loads do not consume a user’s login allowance. - Follow Cloudflare’s rate limiting best practices by layering rules: allow a few normal attempts, trigger a Managed Challenge on mild bursts, and Block sustained abuse over longer windows.
- Test new rules in Log (where available on your plan) or conservative thresholds first so you do not lock out legitimate editors sharing one office IP.
Why single-threshold “block immediately” rules cause false positives
A common mistake is creating one aggressive rule such as “Block any IP that hits /wp-login.php more than 3 times in 1 minute.”
That backfires in two ways:
- Shared office or mobile carrier NAT IPs: Ten staff members or students behind the same university or corporate Wi-Fi share one public IPv4 address.
- Honest password typos: A legitimate editor who mistypes a password twice and refreshes the page should see a challenge, not a hard 1-hour IP ban.
As Cloudflare’s rate limiting best practices illustrate, a tiered approach solves both problems: challenge small bursts first (which humans pass and simple scripts fail), and escalate to a block only when higher thresholds are crossed.
Step-by-step: Build a tiered login rate limit on Cloudflare
1. Match the exact login path and HTTP method
In the Cloudflare dashboard under Security > WAF > Rate limiting rules, target only credential-submission requests:
(http.request.method eq "POST") and (http.request.uri.path eq "/wp-login.php" or http.request.uri.path eq "/user/login")
Notice we match http.request.method eq "POST" rather than all methods, and use exact path matching (or lowercase normalization if your origin is case-insensitive).
2. Layer Rule 1 (Managed Challenge) and Rule 2 (Block)
- Rule 1 — Mild Burst (Managed Challenge):
- When incoming requests match:
POSTto/wp-login.phpor/user/login - Characteristics: IP (or IP + path)
- Rate: Over 4 requests per 1 minute (adjust based on your team size)
- Action: Managed Challenge
- When incoming requests match:
- Rule 2 — Sustained Abuse (Block):
- When incoming requests match: Same
POSTlogin expression - Rate: Over 12 requests per 10 minutes (on plans supporting longer windows, or your plan’s supported period)
- Action: Block for the duration your plan supports
- When incoming requests match: Same
If you run a WordPress site, also consider blocking or challenging /xmlrpc.php unless you specifically rely on Jetpack or the WordPress mobile app.
3. Pair login rate limits with Managed Rules and HSTS
Rate limiting works best alongside Cloudflare’s WAF Managed Rules (which run right after the rate-limiting phase, per Cloudflare’s Managed Rules docs) and clean HTTPS settings. For broader Cloudflare hardening and edge reliability, review enabling Cloudflare HSTS safely and separating browser vs. edge caching with CDN-Cache-Control.
4. Verify in Security Events
After enabling the rule, open Security > Events in Cloudflare and test a few controlled POST requests from a test terminal or browser. Confirm:
- Normal single logins pass with zero friction.
- Rapid bursts trigger
Managed ChallengeorBlockas expected. - No legitimate API webhooks or headless OAuth callbacks share the rate-limited path.
Common mistakes
- Rate limiting
GETrequests on/wp-login.phpor/user/login. A single login flow can involveGET,POST, and redirects; countingGETrequests burns through your threshold prematurely. - Forgetting to check your Cloudflare plan’s period and rule limits. Free, Pro, Business, and Enterprise plans support different rate-limiting periods and counting-expression features—verify what your dashboard allows before designing multi-hour windows.
- Relying on WAF rate limiting while leaving weak passwords or no 2FA/passkeys. Rate limiting slows brute force dramatically, yet leaked passwords from other breaches still work on the first try unless you enforce 2FA or passkeys—see how to use passkeys without losing account access.
- Leaving origin servers directly reachable by IP. If attackers bypass Cloudflare and hit your origin VPS IP directly on port 443, Cloudflare WAF rules never see those requests. Lock origin firewall rules to Cloudflare IP ranges or use Authenticated Origin Pulls.
Why this matters
Credential stuffing is automated, noisy, and relentless. Dropping abusive login POST bursts at Cloudflare’s edge keeps your origin database and PHP workers free for real visitors while stopping basic password-spraying scripts cleanly.
My Take
Every WordPress or Drupal site behind Cloudflare should have at least one POST-only rate-limiting rule on its login path. Start with a Managed Challenge at a reasonable 1-minute threshold so real users behind shared office Wi-Fi never hit a brick wall, and check Security > Events a week later to tune it.
Conclusion
Create a Cloudflare WAF Rate Limiting rule targeting POST requests on your login endpoints, trigger a Managed Challenge before escalating to Block, lock down origin IP access so attackers cannot bypass Cloudflare, and monitor Security > Events after rollout.