$limit_conn_status
$limit_conn_status returns the status of connection limiting on a per-client basis in NGINX. — NGINX Core (HTTP)
Description
The variable $limit_conn_status is used within NGINX to indicate the status of connection limits applied to requests coming from clients. When connection limiting is enabled via the 'limit_conn' directives, this variable is set to reflect the status of the client's connections in relation to the defined limits. Typical values for this variable include 'none' (indicating no limit is exceeded), 'exceeded' (when the client exceeds the allowed number of connections), or 'aborted' (when connection handling is aborted). The value of $limit_conn_status is especially useful for logging purposes or for conditional processing within NGINX configuration. It provides important feedback about the connection limits imposed on clients by the server. This feedback can be utilized to create custom responses or to log specific events based on client connection behavior. NGINX sets this variable during the processing of a request after evaluating the connection limits imposed by directives such as 'limit_conn_zone' and 'limit_conn'.
Config Example
http {
limit_conn_zone $binary_remote_addr zone=addr:10m;
server {
limit_conn addr 1;
location / {
if ($limit_conn_status = exceeded) {
return 503;
}
# Other configurations...
}
}
}Subsystem
httpCacheable
NoContexts
http, server, location, ifEnsure 'limit_conn' directive is declared before any location or server block, otherwise it won't take effect.
Not all contexts support the use of this variable, paying attention to the appropriate scope is crucial.
Using it outside of intended limits can lead to unexpected behaviors in your configuration.