IP Allowlist and Rate Limit Configuration Scenarios
Project: flex-rate-limit
Date: 2026-02-05
Document type: configuration scenario guide
Four Core Questions
Question 1: The Limiter Is Configured for /internal, but the Allowlist Is Not
Code example:
Result:
Key logic:
Summary:
- No allowlist configuration means the route is open to all IPs.
- Every IP can access the route, but every IP is still rate limited.
- This fits public APIs such as
/api/public/data.
Question 2: The Allowlist Is Configured for /internal, but the Limiter Is Not
Code example:
Result:
Key points:
- Non-allowlisted IPs receive
403 Forbidden. - Allowlisted IPs have unrestricted access because there is no limiter on the route.
- This can be a security and abuse risk.
Summary:
- This setup is not recommended.
- Prefer allowlist + rate limiting together.
- A rare exception may be an internal monitoring endpoint where the upstream system already controls volume.
Question 3: Both Allowlist and Rate Limiting Are Configured for /internal
Recommended code:
Result:
Configuration example:
Summary:
- This is the recommended setup.
- It provides two layers: access control and rate control.
- The controls remain independent.
- It fits admin consoles, internal APIs, and sensitive operations.
Question 4: Can the Allowlist Be Global?
Yes. A global allowlist is supported and often useful.
Option 1: Global Allowlist for All Routes
How it works:
Effect:
Option 2: Global Allowlist plus Route Allowlist
Priority:
Scenario Comparison
Configuration Decision Tree
Complete Configuration Examples
Example 1: Public API
Effect:
- Any IP can access the route.
- Every IP is limited to 100 requests per minute.
Example 2: Admin Console
Effect:
- Non-allowlisted IPs receive
403 Forbidden. - Allowlisted IPs are accepted for requests 1-200.
- Allowlisted IPs receive
429 Too Many Requestson request 201+.
Example 3: Internal API
Effect:
- External IPs receive
403 Forbidden. - Private network IPs are allowed up to 5000 requests per minute.
- Private network IPs receive
429 Too Many Requestsafter the quota.
Example 4: Global Allowlist with Route-Specific Limits
Effect:
- Global allowlisted IPs can access all routes.
- Each operation still has its own rate limit.
- Non-global IPs can access routes without route allowlists.
Example 5: Mixed Global and Route Allowlists
Effect:
- Global allowlisted IPs bypass route allowlist validation, then go through rate limiting.
- Route allowlisted IPs pass route validation, then go through rate limiting.
- Other IPs receive
403 Forbidden.
Configuration Management
Environment Variables
Configuration File
Create config/ip-whitelist.json:
Runtime Management
Important Notes
No Allowlist Means All IPs Are Allowed
Correct practice:
- If you do not need access control, do not use the allowlist middleware.
- If you need access control, configure an explicit IP list.
Allowlist and Rate Limit Independence
Incorrect understanding:
Correct understanding:
Global Allowlist Priority
Global allowlisted IPs skip route allowlist validation, but still go through each route's limiter.
Security Recommendations
Related Documents
- Full implementation:
examples/express-ip-whitelist-independent.js - Comparison guide: Allowlist and Rate Limit Independence
- Dynamic configuration: Dynamic IP Allowlist Configuration
- Advanced usage: Advanced Usage