annotate xml/en/docs/http/ngx_http_limit_conn_module.xml @ 870:6087d3fa6919

The limit_req_status and limit_conn_status directives.
author Maxim Dounin <mdounin@mdounin.ru>
date Wed, 20 Mar 2013 21:47:21 +0400
parents af3f38e349eb
children 95c3c3bbf1ce
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
222
bfe3eff81d04 Removed redundant encoding specification.
Ruslan Ermilov <ru@nginx.com>
parents: 207
diff changeset
1 <?xml version="1.0"?>
179
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
2
580
be54c443235a Added copyright markers to documentation sources.
Ruslan Ermilov <ru@nginx.com>
parents: 575
diff changeset
3 <!--
be54c443235a Added copyright markers to documentation sources.
Ruslan Ermilov <ru@nginx.com>
parents: 575
diff changeset
4 Copyright (C) Igor Sysoev
be54c443235a Added copyright markers to documentation sources.
Ruslan Ermilov <ru@nginx.com>
parents: 575
diff changeset
5 Copyright (C) Nginx, Inc.
be54c443235a Added copyright markers to documentation sources.
Ruslan Ermilov <ru@nginx.com>
parents: 575
diff changeset
6 -->
be54c443235a Added copyright markers to documentation sources.
Ruslan Ermilov <ru@nginx.com>
parents: 575
diff changeset
7
179
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
8 <!DOCTYPE module SYSTEM "../../../../dtd/module.dtd">
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
9
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
10 <module name="Module ngx_http_limit_conn_module"
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
11 link="/en/docs/http/ngx_http_limit_conn_module.html"
589
764fbac1b8b4 Added document revision.
Ruslan Ermilov <ru@nginx.com>
parents: 580
diff changeset
12 lang="en"
870
6087d3fa6919 The limit_req_status and limit_conn_status directives.
Maxim Dounin <mdounin@mdounin.ru>
parents: 625
diff changeset
13 rev="2">
179
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
14
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
15 <section id="summary">
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
16
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
17 <para>
271
4c6d2c614d2c Cleaned up XML tag mess:
Ruslan Ermilov <ru@nginx.com>
parents: 270
diff changeset
18 The <literal>ngx_http_limit_conn_module</literal> module allows
179
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
19 to limit the number of connections per defined key, in
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
20 particular, the number of connections from a single IP address.
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
21 </para>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
22
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
23 <para>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
24 Not all connections are counted; only those that have requests
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
25 currently being processed by the server, in which request header has
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
26 been fully read.
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
27 </para>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
28
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
29 </section>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
30
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
31
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
32 <section id="example" name="Example Configuration">
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
33
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
34 <para>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
35 <example>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
36 http {
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
37 limit_conn_zone $binary_remote_addr zone=addr:10m;
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
38
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
39 ...
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
40
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
41 server {
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
42
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
43 ...
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
44
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
45 location /download/ {
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
46 limit_conn addr 1;
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
47 }
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
48 </example>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
49 </para>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
50
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
51 </section>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
52
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
53
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
54 <section id="directives" name="Directives">
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
55
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
56 <directive name="limit_conn">
271
4c6d2c614d2c Cleaned up XML tag mess:
Ruslan Ermilov <ru@nginx.com>
parents: 270
diff changeset
57 <syntax><value>zone</value> <value>number</value></syntax>
179
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
58 <default/>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
59 <context>http</context>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
60 <context>server</context>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
61 <context>location</context>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
62
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
63 <para>
575
ebcb351d9eb3 Consistently using the term "shared memory zone".
Ruslan Ermilov <ru@nginx.com>
parents: 390
diff changeset
64 Sets a shared memory zone
ebcb351d9eb3 Consistently using the term "shared memory zone".
Ruslan Ermilov <ru@nginx.com>
parents: 390
diff changeset
65 and the maximum allowed number of connections for a given key value.
179
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
66 When this limit is exceeded, the server will return error
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
67 <http-status code="503" text="Service Temporarily Unavailable"/>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
68 in reply to a request.
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
69 For example, the directives
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
70 <example>
351
a4fa80755eab Consistently strip initial offset in examples.
Ruslan Ermilov <ru@nginx.com>
parents: 271
diff changeset
71 limit_conn_zone $binary_remote_addr zone=addr:10m;
179
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
72
351
a4fa80755eab Consistently strip initial offset in examples.
Ruslan Ermilov <ru@nginx.com>
parents: 271
diff changeset
73 server {
a4fa80755eab Consistently strip initial offset in examples.
Ruslan Ermilov <ru@nginx.com>
parents: 271
diff changeset
74 location /download/ {
a4fa80755eab Consistently strip initial offset in examples.
Ruslan Ermilov <ru@nginx.com>
parents: 271
diff changeset
75 limit_conn addr 1;
a4fa80755eab Consistently strip initial offset in examples.
Ruslan Ermilov <ru@nginx.com>
parents: 271
diff changeset
76 }
179
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
77 </example>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
78 allow for only a single connection at a time, per unique IP address.
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
79 </para>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
80
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
81 <para>
271
4c6d2c614d2c Cleaned up XML tag mess:
Ruslan Ermilov <ru@nginx.com>
parents: 270
diff changeset
82 When several <literal>limit_conn</literal> directives are specified,
179
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
83 any configured limit will apply.
207
2df68271c898 Provided an example of using several "limit_conn" directives.
Ruslan Ermilov <ru@nginx.com>
parents: 180
diff changeset
84 For example, the following configuration will limit the number
2df68271c898 Provided an example of using several "limit_conn" directives.
Ruslan Ermilov <ru@nginx.com>
parents: 180
diff changeset
85 of connections to the server per client IP and at the same time
2df68271c898 Provided an example of using several "limit_conn" directives.
Ruslan Ermilov <ru@nginx.com>
parents: 180
diff changeset
86 will limit the total number of connections to the virtual host:
2df68271c898 Provided an example of using several "limit_conn" directives.
Ruslan Ermilov <ru@nginx.com>
parents: 180
diff changeset
87 <example>
351
a4fa80755eab Consistently strip initial offset in examples.
Ruslan Ermilov <ru@nginx.com>
parents: 271
diff changeset
88 limit_conn_zone $binary_remote_addr zone=perip:10m;
a4fa80755eab Consistently strip initial offset in examples.
Ruslan Ermilov <ru@nginx.com>
parents: 271
diff changeset
89 limit_conn_zone $server_name zone=perserver:10m;
207
2df68271c898 Provided an example of using several "limit_conn" directives.
Ruslan Ermilov <ru@nginx.com>
parents: 180
diff changeset
90
351
a4fa80755eab Consistently strip initial offset in examples.
Ruslan Ermilov <ru@nginx.com>
parents: 271
diff changeset
91 server {
a4fa80755eab Consistently strip initial offset in examples.
Ruslan Ermilov <ru@nginx.com>
parents: 271
diff changeset
92 ...
a4fa80755eab Consistently strip initial offset in examples.
Ruslan Ermilov <ru@nginx.com>
parents: 271
diff changeset
93 limit_conn perip 10;
a4fa80755eab Consistently strip initial offset in examples.
Ruslan Ermilov <ru@nginx.com>
parents: 271
diff changeset
94 limit_conn perserver 100;
a4fa80755eab Consistently strip initial offset in examples.
Ruslan Ermilov <ru@nginx.com>
parents: 271
diff changeset
95 }
207
2df68271c898 Provided an example of using several "limit_conn" directives.
Ruslan Ermilov <ru@nginx.com>
parents: 180
diff changeset
96 </example>
2df68271c898 Provided an example of using several "limit_conn" directives.
Ruslan Ermilov <ru@nginx.com>
parents: 180
diff changeset
97
179
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
98 </para>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
99
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
100 <para>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
101 These directives are inherited from the previous level if and
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
102 only if there are no
271
4c6d2c614d2c Cleaned up XML tag mess:
Ruslan Ermilov <ru@nginx.com>
parents: 270
diff changeset
103 <literal>limit_conn</literal>
179
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
104 directives on the current level.
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
105 </para>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
106
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
107 </directive>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
108
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
109
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
110 <directive name="limit_conn_log_level">
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
111 <syntax>
271
4c6d2c614d2c Cleaned up XML tag mess:
Ruslan Ermilov <ru@nginx.com>
parents: 270
diff changeset
112 <literal>info</literal> |
4c6d2c614d2c Cleaned up XML tag mess:
Ruslan Ermilov <ru@nginx.com>
parents: 270
diff changeset
113 <literal>notice</literal> |
4c6d2c614d2c Cleaned up XML tag mess:
Ruslan Ermilov <ru@nginx.com>
parents: 270
diff changeset
114 <literal>warn</literal> |
4c6d2c614d2c Cleaned up XML tag mess:
Ruslan Ermilov <ru@nginx.com>
parents: 270
diff changeset
115 <literal>error</literal></syntax>
179
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
116 <default>error</default>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
117 <context>http</context>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
118 <context>server</context>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
119 <context>location</context>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
120 <appeared-in>0.8.18</appeared-in>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
121
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
122 <para>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
123 Sets the desired logging level for cases when the server
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
124 limits the number of connections.
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
125 </para>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
126
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
127 </directive>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
128
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
129
870
6087d3fa6919 The limit_req_status and limit_conn_status directives.
Maxim Dounin <mdounin@mdounin.ru>
parents: 625
diff changeset
130 <directive name="limit_conn_status">
6087d3fa6919 The limit_req_status and limit_conn_status directives.
Maxim Dounin <mdounin@mdounin.ru>
parents: 625
diff changeset
131 <syntax><value>code</value></syntax>
6087d3fa6919 The limit_req_status and limit_conn_status directives.
Maxim Dounin <mdounin@mdounin.ru>
parents: 625
diff changeset
132 <default>503</default>
6087d3fa6919 The limit_req_status and limit_conn_status directives.
Maxim Dounin <mdounin@mdounin.ru>
parents: 625
diff changeset
133 <context>http</context>
6087d3fa6919 The limit_req_status and limit_conn_status directives.
Maxim Dounin <mdounin@mdounin.ru>
parents: 625
diff changeset
134 <context>server</context>
6087d3fa6919 The limit_req_status and limit_conn_status directives.
Maxim Dounin <mdounin@mdounin.ru>
parents: 625
diff changeset
135 <context>location</context>
6087d3fa6919 The limit_req_status and limit_conn_status directives.
Maxim Dounin <mdounin@mdounin.ru>
parents: 625
diff changeset
136 <appeared-in>1.3.15</appeared-in>
6087d3fa6919 The limit_req_status and limit_conn_status directives.
Maxim Dounin <mdounin@mdounin.ru>
parents: 625
diff changeset
137
6087d3fa6919 The limit_req_status and limit_conn_status directives.
Maxim Dounin <mdounin@mdounin.ru>
parents: 625
diff changeset
138 <para>
6087d3fa6919 The limit_req_status and limit_conn_status directives.
Maxim Dounin <mdounin@mdounin.ru>
parents: 625
diff changeset
139 Sets status code to be used when requests are rejected.
6087d3fa6919 The limit_req_status and limit_conn_status directives.
Maxim Dounin <mdounin@mdounin.ru>
parents: 625
diff changeset
140 </para>
6087d3fa6919 The limit_req_status and limit_conn_status directives.
Maxim Dounin <mdounin@mdounin.ru>
parents: 625
diff changeset
141
6087d3fa6919 The limit_req_status and limit_conn_status directives.
Maxim Dounin <mdounin@mdounin.ru>
parents: 625
diff changeset
142 </directive>
6087d3fa6919 The limit_req_status and limit_conn_status directives.
Maxim Dounin <mdounin@mdounin.ru>
parents: 625
diff changeset
143
6087d3fa6919 The limit_req_status and limit_conn_status directives.
Maxim Dounin <mdounin@mdounin.ru>
parents: 625
diff changeset
144
179
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
145 <directive name="limit_conn_zone">
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
146 <syntax>
271
4c6d2c614d2c Cleaned up XML tag mess:
Ruslan Ermilov <ru@nginx.com>
parents: 270
diff changeset
147 <value>$variable</value>
4c6d2c614d2c Cleaned up XML tag mess:
Ruslan Ermilov <ru@nginx.com>
parents: 270
diff changeset
148 <literal>zone</literal>=<value>name</value>:<value>size</value></syntax>
179
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
149 <default/>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
150 <context>http</context>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
151
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
152 <para>
575
ebcb351d9eb3 Consistently using the term "shared memory zone".
Ruslan Ermilov <ru@nginx.com>
parents: 390
diff changeset
153 Sets parameters of a shared memory zone that keeps states
ebcb351d9eb3 Consistently using the term "shared memory zone".
Ruslan Ermilov <ru@nginx.com>
parents: 390
diff changeset
154 for various keys.
179
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
155 This state stores the current number of connections in particular.
390
bef9e1a2e3c8 Documented the fact that empty values are not accounted in zones.
Ruslan Ermilov <ru@nginx.com>
parents: 364
diff changeset
156 The key is any non-empty value of the specified variable
bef9e1a2e3c8 Documented the fact that empty values are not accounted in zones.
Ruslan Ermilov <ru@nginx.com>
parents: 364
diff changeset
157 (empty values are not accounted).
179
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
158 Example usage:
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
159 <example>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
160 limit_conn_zone $binary_remote_addr zone=addr:10m;
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
161 </example>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
162 Here, an IP address of the client serves as a key.
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
163 Note that instead of <var>$remote_addr</var>, the
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
164 <var>$binary_remote_addr</var> variable is used here.
625
af3f38e349eb Removed terminal whitespace and fixed apostrophes used.
Ruslan Ermilov <ru@nginx.com>
parents: 609
diff changeset
165 The length of the <var>$remote_addr</var> variable’s value can
179
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
166 range from 7 to 15 bytes, and the stored state occupies either
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
167 32 or 64 bytes of memory on 32-bit platforms, and always 64
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
168 bytes on 64-bit platforms.
625
af3f38e349eb Removed terminal whitespace and fixed apostrophes used.
Ruslan Ermilov <ru@nginx.com>
parents: 609
diff changeset
169 The length of the <var>$binary_remote_addr</var> variable’s value
179
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
170 is always 4 bytes, and the stored state always occupies 32 bytes
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
171 on 32-bit platforms, and 64 bytes on 64-bit platforms.
609
39a51e664374 Typo fixed.
Maxim Dounin <mdounin@mdounin.ru>
parents: 589
diff changeset
172 One megabyte zone can keep about 32 thousand 32-byte states,
179
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
173 and about 16 thousand 64-byte states.
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
174 If the storage for a zone is exhausted, the server will return error
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
175 <http-status code="503" text="Service Temporarily Unavailable"/>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
176 to all further requests.
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
177 </para>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
178
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
179 </directive>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
180
364
bb51d3e17dd0 Style fixed.
Ruslan Ermilov <ru@nginx.com>
parents: 351
diff changeset
181
179
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
182 <directive name="limit_zone">
270
945d7299c26c Spaces are now preserved here, so removed all the hacks.
Ruslan Ermilov <ru@nginx.com>
parents: 227
diff changeset
183 <syntax>
271
4c6d2c614d2c Cleaned up XML tag mess:
Ruslan Ermilov <ru@nginx.com>
parents: 270
diff changeset
184 <value>name</value>
4c6d2c614d2c Cleaned up XML tag mess:
Ruslan Ermilov <ru@nginx.com>
parents: 270
diff changeset
185 <value>$variable</value>
4c6d2c614d2c Cleaned up XML tag mess:
Ruslan Ermilov <ru@nginx.com>
parents: 270
diff changeset
186 <value>size</value></syntax>
179
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
187 <default/>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
188 <context>http</context>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
189
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
190 <para>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
191 This directive is made obsolete in version 1.1.8,
180
9e7d0c9c7eaa Mentioned the compatible "limit_conn_zone" directive syntax for the
Ruslan Ermilov <ru@nginx.com>
parents: 179
diff changeset
192 an equivalent <link id="limit_conn_zone"/> directive
9e7d0c9c7eaa Mentioned the compatible "limit_conn_zone" directive syntax for the
Ruslan Ermilov <ru@nginx.com>
parents: 179
diff changeset
193 with a changed syntax should be used instead:
9e7d0c9c7eaa Mentioned the compatible "limit_conn_zone" directive syntax for the
Ruslan Ermilov <ru@nginx.com>
parents: 179
diff changeset
194 <note>
271
4c6d2c614d2c Cleaned up XML tag mess:
Ruslan Ermilov <ru@nginx.com>
parents: 270
diff changeset
195 <literal>limit_conn_zone</literal>
4c6d2c614d2c Cleaned up XML tag mess:
Ruslan Ermilov <ru@nginx.com>
parents: 270
diff changeset
196 <value>$variable</value>
4c6d2c614d2c Cleaned up XML tag mess:
Ruslan Ermilov <ru@nginx.com>
parents: 270
diff changeset
197 <literal>zone</literal>=<value>name</value>:<value>size</value>;
180
9e7d0c9c7eaa Mentioned the compatible "limit_conn_zone" directive syntax for the
Ruslan Ermilov <ru@nginx.com>
parents: 179
diff changeset
198 </note>
179
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
199 </para>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
200
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
201 </directive>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
202
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
203 </section>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
204
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
205 </module>