The right way
# wrong — the second line overwrites the first, the rate limit is gone
- "traefik.http.routers.app-https.middlewares=global-ratelimit@file"
- "traefik.http.routers.app-https.middlewares=crowdsec@file"
# right
- "traefik.http.routers.app-https.middlewares=crowdsec@file,global-ratelimit@file"
The order in the line is the order in the chain: put crowdsec@file first, so a banned client gets 403 before
any other check (CrowdSec with Traefik behind Cloudflare).
If it doesn’t work
Added CrowdSec to a router — the rate limit disappeared
- Cause
- The middlewares are written as two labels with the same key, and only the last one applies.
- Fix
- Merge them into one line:
middlewares=crowdsec@file,global-ratelimit@file.
How to check
The Traefik dashboard or API lists routers and their middlewares: the router should have every one listed in the line.