comparison xml/en/docs/http/ngx_http_limit_conn_module.xml @ 966:95c3c3bbf1ce

Text review.
author Egor Nikitin <yegor.nikitin@gmail.com>
date Wed, 14 Aug 2013 12:03:41 +0400
parents 6087d3fa6919
children 91a4eee45eb7
comparison
equal deleted inserted replaced
965:fadccc156188 966:95c3c3bbf1ce
13 rev="2"> 13 rev="2">
14 14
15 <section id="summary"> 15 <section id="summary">
16 16
17 <para> 17 <para>
18 The <literal>ngx_http_limit_conn_module</literal> module allows 18 The <literal>ngx_http_limit_conn_module</literal> module is used to
19 to limit the number of connections per defined key, in 19 limit the number of connections per the defined key, in
20 particular, the number of connections from a single IP address. 20 particular, the number of connections from a single IP address.
21 </para> 21 </para>
22 22
23 <para> 23 <para>
24 Not all connections are counted; only those that have requests 24 Not all connections are counted.
25 currently being processed by the server, in which request header has 25 A connection is counted only if it has a request processed by the server
26 been fully read. 26 and the whole request header has already been read.
27 </para> 27 </para>
28 28
29 </section> 29 </section>
30 30
31 31
59 <context>http</context> 59 <context>http</context>
60 <context>server</context> 60 <context>server</context>
61 <context>location</context> 61 <context>location</context>
62 62
63 <para> 63 <para>
64 Sets a shared memory zone 64 Sets the shared memory zone
65 and the maximum allowed number of connections for a given key value. 65 and the maximum allowed number of connections for a given key value.
66 When this limit is exceeded, the server will return error 66 When this limit is exceeded, the server will return the
67 <http-status code="503" text="Service Temporarily Unavailable"/> 67 <http-status code="503" text="Service Temporarily Unavailable"/>
68 in reply to a request. 68 error in reply to a request.
69 For example, the directives 69 For example, the directives
70 <example> 70 <example>
71 limit_conn_zone $binary_remote_addr zone=addr:10m; 71 limit_conn_zone $binary_remote_addr zone=addr:10m;
72 72
73 server { 73 server {
74 location /download/ { 74 location /download/ {
75 limit_conn addr 1; 75 limit_conn addr 1;
76 } 76 }
77 </example> 77 </example>
78 allow for only a single connection at a time, per unique IP address. 78 allow only one connection per an IP address at a time.
79 </para> 79 </para>
80 80
81 <para> 81 <para>
82 When several <literal>limit_conn</literal> directives are specified, 82 When several <literal>limit_conn</literal> directives are specified,
83 any configured limit will apply. 83 any configured limit will apply.
84 For example, the following configuration will limit the number 84 For example, the following configuration will limit the number
85 of connections to the server per client IP and at the same time 85 of connections to the server per a client IP and, at the same time,
86 will limit the total number of connections to the virtual host: 86 the total number of connections to the virtual host:
87 <example> 87 <example>
88 limit_conn_zone $binary_remote_addr zone=perip:10m; 88 limit_conn_zone $binary_remote_addr zone=perip:10m;
89 limit_conn_zone $server_name zone=perserver:10m; 89 limit_conn_zone $server_name zone=perserver:10m;
90 90
91 server { 91 server {
134 <context>server</context> 134 <context>server</context>
135 <context>location</context> 135 <context>location</context>
136 <appeared-in>1.3.15</appeared-in> 136 <appeared-in>1.3.15</appeared-in>
137 137
138 <para> 138 <para>
139 Sets status code to be used when requests are rejected. 139 Sets the status code to return in response to rejected requests.
140 </para> 140 </para>
141 141
142 </directive> 142 </directive>
143 143
144 144
148 <literal>zone</literal>=<value>name</value>:<value>size</value></syntax> 148 <literal>zone</literal>=<value>name</value>:<value>size</value></syntax>
149 <default/> 149 <default/>
150 <context>http</context> 150 <context>http</context>
151 151
152 <para> 152 <para>
153 Sets parameters of a shared memory zone that keeps states 153 Sets parameters for a shared memory zone
154 for various keys. 154 that will keep states for various keys.
155 This state stores the current number of connections in particular. 155 In particular, the state includes the current number of connections.
156 The key is any non-empty value of the specified variable 156 The key is any non-empty value of the specified variable
157 (empty values are not accounted). 157 (empty values are not accounted).
158 Example usage: 158 Usage example:
159 <example> 159 <example>
160 limit_conn_zone $binary_remote_addr zone=addr:10m; 160 limit_conn_zone $binary_remote_addr zone=addr:10m;
161 </example> 161 </example>
162 Here, an IP address of the client serves as a key. 162 Here, a client IP address serves as a key.
163 Note that instead of <var>$remote_addr</var>, the 163 Note that instead of <var>$remote_addr</var>, the
164 <var>$binary_remote_addr</var> variable is used here. 164 <var>$binary_remote_addr</var> variable is used here.
165 The length of the <var>$remote_addr</var> variable’s value can 165 The <var>$remote_addr</var> variable’s size can
166 range from 7 to 15 bytes, and the stored state occupies either 166 vary from 7 to 15 bytes.
167 32 or 64 bytes of memory on 32-bit platforms, and always 64 167 The stored state occupies either
168 32 or 64 bytes of memory on 32-bit platforms and always 64
168 bytes on 64-bit platforms. 169 bytes on 64-bit platforms.
169 The length of the <var>$binary_remote_addr</var> variable’s value 170 The <var>$binary_remote_addr</var> variable’s size
170 is always 4 bytes, and the stored state always occupies 32 bytes 171 is always 4 bytes.
171 on 32-bit platforms, and 64 bytes on 64-bit platforms. 172 The stored state always occupies 32 bytes
172 One megabyte zone can keep about 32 thousand 32-byte states, 173 on 32-bit platforms and 64 bytes on 64-bit platforms.
173 and about 16 thousand 64-byte states. 174 One megabyte zone can keep about 32 thousand 32-byte states
174 If the storage for a zone is exhausted, the server will return error 175 or about 16 thousand 64-byte states.
176 If the zone storage is exhausted, the server will return the
175 <http-status code="503" text="Service Temporarily Unavailable"/> 177 <http-status code="503" text="Service Temporarily Unavailable"/>
176 to all further requests. 178 error to all further requests.
177 </para> 179 </para>
178 180
179 </directive> 181 </directive>
180 182
181 183