Skip to content

Protecting wp-login.php with Cloudflare rate limiting on the Free plan

Use the one rate limiting rule on Cloudflare's Free plan to block fast password-guessing attacks on wp-login.php. You will set it up, test that it fires, and pair it with a custom rule that catches slower attacks.

If you run WordPress behind Cloudflare’s Free plan, you can use its single rate limiting rule to protect your login page, wp-login.php. Rate limiting means counting how many requests one visitor sends in a short time and blocking them past a limit. On Free, the rule counts requests per IP address over a fixed 10-second window, then blocks that IP for 10 seconds when the count passes your threshold. That stops most brute-force floods, where one machine guesses passwords as fast as it can, and it costs nothing. It cannot stop slow or widely distributed attacks, so the article also covers the custom rule to pair with it.

What’s happening

At the edge, Cloudflare evaluates a request through its security layers in order: DDoS mitigation, IP Access rules, WAF custom rules, rate limiting rules, then managed rulesets, with bot products (Bot Fight Mode on Free, Super Bot Fight Mode on Pro and Business) judging alongside. Rate limiting is the only layer that counts — everything else looks at one request at a time, while a rate limiting rule tracks how many matching requests one client sent recently.

The Free plan’s version is deliberately small: one active rule, counting keyed to the source IP only, a counting period fixed at 10 seconds, a mitigation timeout fixed at 10 seconds, and Block as the action. Paid plans add more rules, longer windows and timeouts, challenge actions, and (higher up) counting on things other than IP. What the Free rule allows is still exactly the shape of a login-flood defense: “if one IP sends more than N requests to this path in 10 seconds, block that IP for the next 10 seconds”. Attackers hammering hundreds of attempts per minute from one IP spend most of the attack blocked; a human who fat-fingers a password twice never notices.

What to check first

  • Confirm login traffic actually flows through Cloudflare. The DNS record for the site must be proxied (orange cloud). A grey-cloud record means the edge never sees wp-login.php.
  • Check whether the rule slot is already spent. Security > WAF > Rate limiting rules — Free zones get one rule, so if it is in use you are choosing, not adding.
  • Know your legitimate burst. A single browser login is one GET plus one POST. Shared-office NAT means dozens of users behind one IP — count them before picking a threshold.
  • Check what already protects the path. A managed WordPress ruleset or an existing custom rule may already challenge login traffic; stacking blindly makes debugging harder.

How to verify

Create the rule (below), then prove it fires. Send a burst and watch the status codes flip:

# Fire 15 POSTs inside one 10-second window
for i in $(seq 1 15); do
  curl -s -o /dev/null -w "%{http_code} " \
    -X POST "https://www.example.com/wp-login.php" \
    --data "log=test&pwd=wrong"
done; echo
# Expect: 200/302s, then 429s once the threshold trips

Confirm the events registered at the edge:

Security > Events
  Filter: Service equals Rate limiting rules
  Read:   Action taken = Block, your rule name, the source IP, path /wp-login.php

Then verify from a clean IP — a phone on cellular data — that a single normal login still works while your test IP is inside its 10-second block. If the block never appears, grab a Ray ID from a test response and search it in Security > Events to see which layer answered instead.

The fix

  1. Create the rule. Security > WAF > Rate limiting rules > Create rule. Name it login-burst-block.
  2. Match the login path, POST only. Expression: (http.request.uri.path eq "/wp-login.php" and http.request.method eq "POST"). GETs are humans loading the form and password managers prefetching; POSTs are attempts. Counting POSTs only lets you set a tighter threshold.
  3. Set the threshold for a 10-second window. With per-IP counting, 5 POSTs in 10 seconds is generous for humans — even a shared office rarely produces five login submissions in ten seconds — and miserly for a brute-forcer. Period and mitigation timeout are fixed at 10 seconds on Free; the action is Block.
  4. Deploy and watch Security > Events for a day. Look for blocks on IPs that then solve a login successfully later — that pattern means real users are tripping it and the threshold needs to rise.
  5. Pair it with a WAF custom rule for the slow attackers. The 10-second window cannot see an attacker pacing one attempt every 3 seconds. Spend one of your five free custom rules on a Managed Challenge for all of wp-login.php (skip your own static IP if you have one). Rule mechanics are in WAF custom rules: block, challenge, log, skip, and the WordPress-side picture is in rate limiting wp-login, xmlrpc and REST.
  6. Leave xmlrpc.php out of this rule. It deserves its own treatment — multicall amplification means one request can carry hundreds of credential attempts, so rate limiting barely dents it.

When this fix is wrong

If your users log in from one big shared IP — a campus, a call centre, a store chain on one egress — a per-IP block rule will hit staff during shift changes; use the custom-rule challenge as the primary control instead and set this rule’s threshold high. And if the site has no public login use at all, a challenge or block on the whole path beats counting: nobody legitimate is there to rate-limit.

Common mistakes

  • Counting GET requests, then blocking users whose password manager preloads the form.
  • Setting the threshold to 1 or 2 “to be safe” and locking out everyone who mistypes once.
  • Expecting the rule to stop distributed attacks — a botnet with 2,000 IPs sends 4 attempts each and never trips a per-IP counter.
  • Forgetting the origin is still reachable directly; edge rules protect nothing if attackers hit the server’s IP. Lock the origin down to Cloudflare’s ranges.
  • Blocking the path for logged-in admins’ automation (deployment scripts that authenticate via wp-login.php) instead of moving them to application passwords.

Prevention

Review the rule’s event volume monthly: near-zero matches means the threshold is too loose or attacks moved to xmlrpc.php and the REST API; constant matches from residential ASNs means you should add the challenge rule if you have not. Keep strong passwords and two-factor on the WordPress side regardless — rate limiting slows guessing, it does not make guessing safe. Cloudflare’s rate limiting reference lives under developers.cloudflare.com/waf/, and plan thresholds are compared in rate limiting rules and thresholds.

Tuning edge security so it blocks attacks without blocking customers is ongoing work — Stack Harbor watches those events around the clock under 24/7 Monitoring & Response; book a monitoring and response review.