rate_limit_status
The `rate_limit_status` directive sets the HTTP status code returned when a request exceeds the rate limit.
Description
The rate_limit_status directive in the Redis backed rate limit module for NGINX is used to define the HTTP status code that should be returned when the configured rate limit for requests is exceeded. This allows the server to communicate to clients that their requests have been throttled due to hitting the prescribed limits, ensuring that clients can handle such scenarios appropriately. The directive can be set in http, server, or location contexts, making it flexible to different routing configurations within an NGINX server block.
Upon exceeding the allowed rate limit, the module checks the configured status code in the rate_limit_status directive to determine what response to send back. By default, many applications expect a 429 Too Many Requests status code, which indicates that the user has sent too many requests in a given amount of time. The use of this directive ensures that NGINX can adhere to this standard behavior or allows administrators to customize the response as per their application's requirements.
For example, if a service limits users to 15 requests per minute, exceeding this threshold would trigger the response configured in rate_limit_status, helping manage load effectively and signaling clients to adjust their request rates accordingly for smoother operation.
Config Example
rate_limit_status 429;
Ensure that the status code specified is a valid HTTP status code; otherwise, it may lead to unexpected behavior.
Remember to configure rate limiting contexts (e.g., rate_limit, rate_limit_pass) properly to see the effect of this directive.
If multiple rate_limit_status directives are defined in different contexts, the most specific one applies. Be cautious about overriding behaviors.