---
title: "Rate limit a login page"
description: "Limit how many sign-in attempts each client IP can make, first in log-only mode, then blocking."
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.ezghcloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Rate limit a login page

1. Add a rate limit rule to the WAF's `rules`, in log-only mode. It counts each client IP's `POST`s to
   `/login` and records those over 20 in 5 minutes:

   ```json
   {
     "name": "login",
     "action": "rateLimit",
     "mode": "log",
     "rateLimit": { "limit": 20, "windowSeconds": 300 },
     "conditions": [
       { "type": "equals", "negate": false, "target": "path", "value": "/login", "caseSensitive": false },
       { "type": "equals", "negate": false, "target": "method", "value": "POST", "caseSensitive": false }
     ]
   }
   ```

   Replace the WAF with [UpdateWaf](/waf-api/UpdateWaf/), sending the `ETag` you read in
   `If-Match`.

2. With [logging](/waf/logging) on, see which clients went over:

   ```sh
   ezgh obs search --environment production --service ezgh.waf --from 1d --contains '"terminatingRule":{"name":"login"'
   ```

3. If only abusive clients show up, change the rule's `mode` to `block`. Clients over the limit are
   answered `403` until their count in the last 5 minutes falls back under 20.

A client behind a shared address, such as an office's network, shares its count with everyone there.
Exempt such an address with an `allow` rule above the limit.

Source: https://docs.ezghcloud.com/waf/guides/rate-limit-a-login-page/index.mdx
