Imagine a React and NestJS app behind Azure Front Door. One night, the login endpoint receives thousands of attempts a minute from a list of leaked passwords. The NestJS rate limiter is there, but it sees Front Door's addresses rather than the attackers', and every request still reaches the API, the database, and the password hashing that makes logins deliberately slow.
Rate limiting at the edge stops much of that volume before it reaches your servers. It's useful, but it's approximate, and it can't replace limits inside your app.
A sound setup comes down to a few rules:
- Add Front Door WAF rate-limit rules on sensitive paths, such as login, signup, and password reset.
- Understand that the counts are approximate and per edge location, and size thresholds with that in mind.
- Use the connecting socket IP, never a header the client can set, for decisions.
- Lock your origin so attackers can't bypass Front Door.
- Roll rules out in detection or log mode first, and tune them with logs.
- Keep per-account limits in NestJS, because the edge only sees IP addresses.
What edge limits are good for, and what they aren't
An edge rule can reject floods of requests from one source before they cost you compute, database connections, or password hashing. That's a real benefit during credential stuffing, signup spam, or invite abuse.
What it can't do is stop an attacker who spreads requests across many IP addresses. The OWASP Credential Stuffing Prevention Cheat Sheet is explicit that IP-based blocking shouldn't be used as the sole or primary defense. Its Authentication Cheat Sheet recommends tying failed-login counters to the account rather than the source IP. Plan for both layers.
How Front Door rate limits work
Rate limiting in Azure Web Application Firewall on Front Door is a kind of custom rule. Microsoft's rate limiting documentation describes the parts:
- A window of one or five minutes.
- A threshold: the number of matching requests allowed in that window.
- At least one match condition, such as a request path. To count every request, Microsoft's configuration guide uses a condition that always matches.
- Grouping: by default, requests are counted per socket IP address, the address of the connection that reached Front Door. As of November 2026, other groupings, such as by geography or with no grouping, are in preview and require the Premium tier.
Windows are fixed. Once a client goes over the threshold, it's blocked for the rest of that window.
The counts are approximate
This is the detail that changes how you set thresholds. The documentation explains two effects:
- Each edge location counts on its own. Counts aren't shared between Front Door edge locations or combined globally. A client whose requests reach two locations is counted twice, separately.
- Within a location, counting can lag. Requests may land on a server whose count hasn't caught up yet. Microsoft notes that at low thresholds, below about 200 requests per minute, some requests above the threshold can get through.
Login limits often sit exactly in that low range. A rule of "10 login attempts per minute" won't stop the 11th request reliably. Treat edge limits as a way to cut large volumes, and let the app enforce precise limits.
Choosing thresholds
Pick thresholds from your own traffic, not from a number in a blog post:
- Start with logging. Run the rule in a mode that records matches without blocking, and look at how many requests real users send per window.
- Remember shared addresses. Many users behind one corporate network or mobile carrier can share an IP address. A threshold that suits one person can block an office.
- Scope rules to sensitive paths. A strict rule on
/auth/loginand a looser one for the rest of the API are easier to reason about than one global limit.
Which IP address does the rule use?
There are two kinds of "client IP" in play, and the difference matters. The socket address is the address of the connection that reached Front Door, and it's what rate limits group by by default. Header-based client IPs are different: Front Door's HTTP headers documentation notes that client IP information carried in headers can be overwritten by the user. For any custom rule that allows or exempts traffic by IP, base it on the socket address, not on a header the client can set. An exemption on a spoofable header is an open door.
Your app has a related problem. The same headers documentation describes how Front Door appends the client's socket address to the X-Forwarded-For header it forwards, after any value the client already sent. In Express, which NestJS uses by default, the behind-proxies guide explains that setting trust proxy to true takes the left-most address, which is the one the client controls. Configure it with the number of trusted proxy hops or the trusted proxy addresses instead, and test what req.ip actually returns.
Lock the origin to Front Door
Edge rules do nothing if attackers can reach your API directly. Microsoft's origin security guidance recommends combining two checks:
- Allow only Front Door's network ranges, using the
AzureFrontDoor.Backendservice tag in network rules. - Check the Front Door ID header,
X-Azure-FDID, against your own Front Door profile's ID, because the service tag covers every Front Door customer.
The documentation warns that IP filtering alone isn't sufficient. On the Premium tier, Private Link can connect Front Door to the origin privately instead.
Roll out safely
A wrong rule can lock out real users, so introduce rules gradually:
- Use detection mode while tuning, and the Log action for new rate-limit rules. The WAF policy settings describe detection mode, which logs instead of blocking, and Microsoft's best practices suggest considering it while tuning. For rate limits, the rate limiting documentation recommends deploying new rules with the Log action before switching to Block.
- Expect a delay. Microsoft's WAF FAQ says most WAF policy deployments finish in less than 20 minutes, and notes that tuning can take several weeks.
- Read the logs. The monitoring documentation explains how to send WAF logs to Log Analytics. Entries record both the client IP from the header and the socket IP, plus the rule and action, so you can see which addresses hit a rule and how often. Check column names in your own workspace before saving queries.
The tuning guide covers handling false positives once rules are blocking.
What the client gets back
When the WAF blocks a request, it sends its own response, not your API's. The custom response documentation explains that you can customize the block response in the policy settings, and that when the custom body is left blank, rate-limit blocks return 429 Too Many Requests. Two details:
- The custom response lives in the policy settings, so changing it affects blocked requests across the policy, not just rate limits. Test what your rate-limit blocks actually return after any change.
- Don't count on a Retry-After header. RFC 9110 defines it, and RFC 6585 suggests it for 429, but Front Door's documentation doesn't describe adding one to WAF responses.
In React, treat a 429 or a WAF block on login as "too many attempts, try again shortly," and don't retry automatically.
Tiers and the classic retirement
Front Door's tier comparison and the WAF overview set out what each tier includes. As of November 2026, the Standard tier supports custom rules, including rate limits. Premium adds managed rule sets, bot protection, JavaScript and CAPTCHA challenges, the preview groupings, an HTTP DDoS ruleset, and Private Link to origins.
If you're still on Front Door (classic), the tier comparison page says it retires on March 31, 2027, so plan the move to Standard or Premium.
Bots and challenges
Premium offers a JavaScript challenge and a CAPTCHA challenge as rule actions. Both are designed for browser page loads. Microsoft's documentation notes that AJAX and API calls aren't supported, so a React app calling a JSON login API with fetch can't complete a challenge. Use challenges on pages the browser loads directly, not on API routes.
Keep per-account limits in NestJS
Two limits make the app layer essential:
- The edge sees IP addresses, not accounts. An attacker rotating addresses stays under every IP threshold while trying the same account.
- Custom rules don't read JSON bodies. Microsoft's WAF FAQ lists only form-encoded bodies (
application/x-www-form-urlencoded) for custom rule body inspection, so a rule can't match the username inside a JSON login request.
In NestJS, the rate limiting module handles per-route limits in the app. For logins, follow OWASP and also count failed attempts per account, slowing down or locking that account rather than the IP address. Make sure the limiter reads the correct client IP, as above.
Checklist
- Add edge rate-limit rules on login, signup, password reset, and invite endpoints.
- Size thresholds from logged traffic, and remember edge counts are approximate and per location.
- Group by socket IP, and never exempt traffic based on X-Forwarded-For.
- Configure Express trust proxy with hop counts or trusted addresses, not
true. - Lock the origin with the service tag and the X-Azure-FDID check.
- Start in detection mode or with Log actions, then switch to Block.
- Send WAF logs to Log Analytics and review rule hits.
- Check what your blocks return, since the custom response is a policy setting.
- Check your tier, and plan the move off Front Door (classic).
- Use challenges only on page loads, not API calls.
- Keep per-account limits and failed-login counters in NestJS.



