This module makes it possible to limit the number of concurrent connections for a defined key such as, for example, an ip address.
|Syntax:||limit_conn zone number|
Sets the maximum allowed number of connections for a given zone. When this limit is exceeded, the server will return a status error 503 (Service Temporarily Unavailable) in reply to the request.
Multiple limit directives for different zones can be used in the same context and each will apply.
Standard nginx inheritance applies. Lower contexts will inherit from higher context so long as there are no similar directives in the current context.
limit_conn_zone $variable |
Sets the parameters for a zone that keeps state for various keys. This state stores the current number of connections in particular. The key is the value of the specified variable. Example usage:
limit_conn_zone $binary_remote_addr zone=addr:10m;
Here, an IP address of the client serves as a key. Note that instead of $remote_addr, the $binary_remote_addr variable is used here. The length of the $remote_addr variable's value can range from 7 to 15 bytes, and the stored state occupies either 32 or 64 bytes of memory on 32-bit platforms, and always 64 bytes on 64-bit platforms. The length of the $binary_remote_addr variable's value is always 4 bytes, and the stored state always occupies 32 bytes on 32-bit platforms, and 64 bytes on 64-bit platforms. One megabyte zone can keep about 32 thousand 32-bit states, and about 16 thousand 64-byte states. If the storage for a zone is exhausted, the server will return error 503 (Service Temporarily Unavailable) to all further requests.
Sets the error log level used when a connection limit is reached.