FAQ

Page Discussion History

Difference between revisions of "HttpLimitZoneModule"

(limit_conn_log_level)
 
(Directives)
(7 intermediate revisions by 2 users not shown)
Line 19: Line 19:
 
= Directives =
 
= Directives =
 
== limit_zone ==
 
== limit_zone ==
'''syntax:''' ''limit_zone zone_name $variable memory_max_size''
+
<include wikitext nopre src="http://wiki.nginx.org/nginx.org/http/ngx_http_limit_conn_module/limit_zone.txt" />
  
'''default:''' ''no''
+
This directive is made obsolete in version 1.1.8, an equivalent limit_conn_zone directive with a changed syntax should be used instead:
  
'''context:''' ''http''
+
<geshi lang="nginx">
 +
limit_conn_zone $variable zone=name:size;
 +
</geshi>
  
 
Directive describes the zone, in which the session states are stored.<BR>
 
Directive describes the zone, in which the session states are stored.<BR>
Line 44: Line 46:
  
 
== limit_conn ==
 
== limit_conn ==
 
+
<include wikitext nopre src="http://wiki.nginx.org/nginx.org/http/ngx_http_limit_conn_module/limit_conn.txt" />
'''syntax:''' ''limit_conn zone_name max_clients_per_ip''
+
 
+
'''default:''' ''no''
+
 
+
'''context:''' ''http, server, location''
+
  
 
Directive assigns the maximum number of simultaneous connections for one session.
 
Directive assigns the maximum number of simultaneous connections for one session.
Line 68: Line 65:
  
 
== limit_conn_log_level ==
 
== limit_conn_log_level ==
 
+
<include wikitext nopre src="http://wiki.nginx.org/nginx.org/http/ngx_http_limit_conn_module/limit_conn_log_level.txt" />
'''syntax:''' ''limit_conn_log_level info | notice | warn | error''
+
 
+
'''default:''' ''error''
+
 
+
'''context:''' ''http, server, location''
+
  
 
Sets the error log level used when a connection limit is reached
 
Sets the error log level used when a connection limit is reached
  
 
= References =
 
= References =
[http://sysoev.ru/nginx/docs/http/ngx_http_limit_zone_module.html Original Documentation]
+
[http://nginx.org/en/docs/http/ngx_http_limit_conn_module.html Original Documentation]

Revision as of 19:33, 2 May 2012

Contents

Synopsis

This module makes it possible to limit the number of simultaneous connections for the assigned session or as a special case, from one address.

Example configuration

http {
  limit_zone   one  $binary_remote_addr  10m;
 
  server {
    location /download/ {
      limit_conn   one  1;
    }
  }
}

Directives

limit_zone

Syntax: limit_zone name $variable size
Default:
Context: http
Reference:limit_zone


This directive is made obsolete in version 1.1.8, an equivalent limit_conn_zone directive with a changed syntax should be used instead:

limit_conn_zone $variable zone=name:size;

Directive describes the zone, in which the session states are stored.
The numbers of sessions is determined by the assigned variable, it depends on the size of the used Variable and memory_max_size value.

Example of the use:

limit_zone one $binary_remote_addr 10m;

The address of client is used as the session. Notice that the variable $binary_remote_addr is used instead of $remote_addr.

The length of the values of the variable of $remote_addr can be from 7 to 15 bytes; therefore size state is equal to 32 or 64 bytes.

Length of all values of the variable of $binary_remote_addr is always 4 bytes and the size of the state is always 32 bytes.

When the zone size is 1M then it is possible to handle 32000 sessions with 32 bytes/session.

limit_conn

Syntax: limit_conn zone number
Default:
Context: http
server
location
Reference:limit_conn


Directive assigns the maximum number of simultaneous connections for one session. With exceeding of this number the request completes by the code "Service unavailable" (503).

For example, the directive:

limit_zone   one  $binary_remote_addr  10m;
 
server {
  location /download/ {
  limit_conn   one  1;
}

This allows not more than one simultaneous connection from one address.

limit_conn_log_level

Syntax: limit_conn_log_level info | notice | warn | error
Default: error
Context: http
server
location
Appeared in: 0.8.18
Reference:limit_conn_log_level


Sets the error log level used when a connection limit is reached

References

Original Documentation