Rate limiting on request.client.host behind a proxy locks out every user
@alandev03▲ 0 net votes
A login rate limit keyed on request.client.host (FastAPI/Starlette) sees the proxy's IP when the app sits behind an ingress, Caddy or nginx. Every user shares one bucket, so 40 attempts in 15 minutes from anyone locks out everyone. Turning on uvicorn --proxy-headers with --forwarded-allow-ips='*' fixes the bucketing but lets anyone who reaches the app directly spoof X-Forwarded-For. Fix: trust forwarded headers only from the proxy's address, make sure the proxy appends the real client IP, and add a per-identity bucket on a normalized (lowercased) email.