annotate xml/en/docs/http/ngx_http_limit_conn_module.xml @ 2013:469aebbd94d0

Limit_req/limit_conn may return not only 503 on failure.
author Ruslan Ermilov <ru@nginx.com>
date Tue, 08 Aug 2017 09:23:25 +0300
parents 6c96a644b0b3
children 4931a7ba6a32
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"
2013
469aebbd94d0 Limit_req/limit_conn may return not only 503 on failure.
Ruslan Ermilov <ru@nginx.com>
parents: 1699
diff changeset
13 rev="10">
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>
966
95c3c3bbf1ce Text review.
Egor Nikitin <yegor.nikitin@gmail.com>
parents: 870
diff changeset
18 The <literal>ngx_http_limit_conn_module</literal> module is used to
95c3c3bbf1ce Text review.
Egor Nikitin <yegor.nikitin@gmail.com>
parents: 870
diff changeset
19 limit the number of connections per the defined key, in
179
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>
966
95c3c3bbf1ce Text review.
Egor Nikitin <yegor.nikitin@gmail.com>
parents: 870
diff changeset
24 Not all connections are counted.
95c3c3bbf1ce Text review.
Egor Nikitin <yegor.nikitin@gmail.com>
parents: 870
diff changeset
25 A connection is counted only if it has a request processed by the server
95c3c3bbf1ce Text review.
Egor Nikitin <yegor.nikitin@gmail.com>
parents: 870
diff changeset
26 and the whole request header has already been read.
179
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>
966
95c3c3bbf1ce Text review.
Egor Nikitin <yegor.nikitin@gmail.com>
parents: 870
diff changeset
64 Sets the shared memory zone
575
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.
966
95c3c3bbf1ce Text review.
Egor Nikitin <yegor.nikitin@gmail.com>
parents: 870
diff changeset
66 When this limit is exceeded, the server will return the
2013
469aebbd94d0 Limit_req/limit_conn may return not only 503 on failure.
Ruslan Ermilov <ru@nginx.com>
parents: 1699
diff changeset
67 <link id="limit_conn_status">error</link>
469aebbd94d0 Limit_req/limit_conn may return not only 503 on failure.
Ruslan Ermilov <ru@nginx.com>
parents: 1699
diff changeset
68 in reply to a request.
179
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>
966
95c3c3bbf1ce Text review.
Egor Nikitin <yegor.nikitin@gmail.com>
parents: 870
diff changeset
78 allow only one connection per an IP address at a time.
1347
7d028fc94593 Added a note about SPDY connections in limit_conn.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 1320
diff changeset
79 <note>
1566
0ca33afb461b Added the http2 module.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 1347
diff changeset
80 In HTTP/2 and SPDY, each concurrent request is considered a separate connection.
1347
7d028fc94593 Added a note about SPDY connections in limit_conn.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 1320
diff changeset
81 </note>
179
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
82 </para>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
83
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
84 <para>
1628
d846df055f03 Disambiguated a sentence about multiple limit_conn limits.
Ruslan Ermilov <ru@nginx.com>
parents: 1623
diff changeset
85 There could be several <literal>limit_conn</literal> directives.
207
2df68271c898 Provided an example of using several "limit_conn" directives.
Ruslan Ermilov <ru@nginx.com>
parents: 180
diff changeset
86 For example, the following configuration will limit the number
966
95c3c3bbf1ce Text review.
Egor Nikitin <yegor.nikitin@gmail.com>
parents: 870
diff changeset
87 of connections to the server per a client IP and, at the same time,
1623
a3509ca11ab4 The term "virtual server" is more common in nginx.
Ruslan Ermilov <ru@nginx.com>
parents: 1566
diff changeset
88 the total number of connections to the virtual server:
207
2df68271c898 Provided an example of using several "limit_conn" directives.
Ruslan Ermilov <ru@nginx.com>
parents: 180
diff changeset
89 <example>
351
a4fa80755eab Consistently strip initial offset in examples.
Ruslan Ermilov <ru@nginx.com>
parents: 271
diff changeset
90 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
91 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
92
351
a4fa80755eab Consistently strip initial offset in examples.
Ruslan Ermilov <ru@nginx.com>
parents: 271
diff changeset
93 server {
a4fa80755eab Consistently strip initial offset in examples.
Ruslan Ermilov <ru@nginx.com>
parents: 271
diff changeset
94 ...
a4fa80755eab Consistently strip initial offset in examples.
Ruslan Ermilov <ru@nginx.com>
parents: 271
diff changeset
95 limit_conn perip 10;
a4fa80755eab Consistently strip initial offset in examples.
Ruslan Ermilov <ru@nginx.com>
parents: 271
diff changeset
96 limit_conn perserver 100;
a4fa80755eab Consistently strip initial offset in examples.
Ruslan Ermilov <ru@nginx.com>
parents: 271
diff changeset
97 }
207
2df68271c898 Provided an example of using several "limit_conn" directives.
Ruslan Ermilov <ru@nginx.com>
parents: 180
diff changeset
98 </example>
2df68271c898 Provided an example of using several "limit_conn" directives.
Ruslan Ermilov <ru@nginx.com>
parents: 180
diff changeset
99
179
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
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
102 <para>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
103 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
104 only if there are no
271
4c6d2c614d2c Cleaned up XML tag mess:
Ruslan Ermilov <ru@nginx.com>
parents: 270
diff changeset
105 <literal>limit_conn</literal>
179
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
106 directives on the current level.
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
107 </para>
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 </directive>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
110
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
111
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
112 <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
113 <syntax>
271
4c6d2c614d2c Cleaned up XML tag mess:
Ruslan Ermilov <ru@nginx.com>
parents: 270
diff changeset
114 <literal>info</literal> |
4c6d2c614d2c Cleaned up XML tag mess:
Ruslan Ermilov <ru@nginx.com>
parents: 270
diff changeset
115 <literal>notice</literal> |
4c6d2c614d2c Cleaned up XML tag mess:
Ruslan Ermilov <ru@nginx.com>
parents: 270
diff changeset
116 <literal>warn</literal> |
4c6d2c614d2c Cleaned up XML tag mess:
Ruslan Ermilov <ru@nginx.com>
parents: 270
diff changeset
117 <literal>error</literal></syntax>
179
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
118 <default>error</default>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
119 <context>http</context>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
120 <context>server</context>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
121 <context>location</context>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
122 <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
123
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
124 <para>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
125 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
126 limits the number of connections.
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
127 </para>
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 </directive>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
130
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
131
870
6087d3fa6919 The limit_req_status and limit_conn_status directives.
Maxim Dounin <mdounin@mdounin.ru>
parents: 625
diff changeset
132 <directive name="limit_conn_status">
6087d3fa6919 The limit_req_status and limit_conn_status directives.
Maxim Dounin <mdounin@mdounin.ru>
parents: 625
diff changeset
133 <syntax><value>code</value></syntax>
6087d3fa6919 The limit_req_status and limit_conn_status directives.
Maxim Dounin <mdounin@mdounin.ru>
parents: 625
diff changeset
134 <default>503</default>
6087d3fa6919 The limit_req_status and limit_conn_status directives.
Maxim Dounin <mdounin@mdounin.ru>
parents: 625
diff changeset
135 <context>http</context>
6087d3fa6919 The limit_req_status and limit_conn_status directives.
Maxim Dounin <mdounin@mdounin.ru>
parents: 625
diff changeset
136 <context>server</context>
6087d3fa6919 The limit_req_status and limit_conn_status directives.
Maxim Dounin <mdounin@mdounin.ru>
parents: 625
diff changeset
137 <context>location</context>
6087d3fa6919 The limit_req_status and limit_conn_status directives.
Maxim Dounin <mdounin@mdounin.ru>
parents: 625
diff changeset
138 <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
139
6087d3fa6919 The limit_req_status and limit_conn_status directives.
Maxim Dounin <mdounin@mdounin.ru>
parents: 625
diff changeset
140 <para>
966
95c3c3bbf1ce Text review.
Egor Nikitin <yegor.nikitin@gmail.com>
parents: 870
diff changeset
141 Sets the status code to return in response to rejected requests.
870
6087d3fa6919 The limit_req_status and limit_conn_status directives.
Maxim Dounin <mdounin@mdounin.ru>
parents: 625
diff changeset
142 </para>
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 </directive>
6087d3fa6919 The limit_req_status and limit_conn_status directives.
Maxim Dounin <mdounin@mdounin.ru>
parents: 625
diff changeset
145
6087d3fa6919 The limit_req_status and limit_conn_status directives.
Maxim Dounin <mdounin@mdounin.ru>
parents: 625
diff changeset
146
179
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
147 <directive name="limit_conn_zone">
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
148 <syntax>
1320
f15a983cac66 Limit conn/req: key is no longer limited to only one variable.
Ruslan Ermilov <ru@nginx.com>
parents: 1312
diff changeset
149 <value>key</value>
271
4c6d2c614d2c Cleaned up XML tag mess:
Ruslan Ermilov <ru@nginx.com>
parents: 270
diff changeset
150 <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
151 <default/>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
152 <context>http</context>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
153
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
154 <para>
966
95c3c3bbf1ce Text review.
Egor Nikitin <yegor.nikitin@gmail.com>
parents: 870
diff changeset
155 Sets parameters for a shared memory zone
95c3c3bbf1ce Text review.
Egor Nikitin <yegor.nikitin@gmail.com>
parents: 870
diff changeset
156 that will keep states for various keys.
95c3c3bbf1ce Text review.
Egor Nikitin <yegor.nikitin@gmail.com>
parents: 870
diff changeset
157 In particular, the state includes the current number of connections.
1320
f15a983cac66 Limit conn/req: key is no longer limited to only one variable.
Ruslan Ermilov <ru@nginx.com>
parents: 1312
diff changeset
158 The <value>key</value> can contain text, variables, and their combination.
f15a983cac66 Limit conn/req: key is no longer limited to only one variable.
Ruslan Ermilov <ru@nginx.com>
parents: 1312
diff changeset
159 Requests with an empty key value are not accounted.
f15a983cac66 Limit conn/req: key is no longer limited to only one variable.
Ruslan Ermilov <ru@nginx.com>
parents: 1312
diff changeset
160 <note>
f15a983cac66 Limit conn/req: key is no longer limited to only one variable.
Ruslan Ermilov <ru@nginx.com>
parents: 1312
diff changeset
161 Prior to version 1.7.6, a <value>key</value> could contain exactly one variable.
f15a983cac66 Limit conn/req: key is no longer limited to only one variable.
Ruslan Ermilov <ru@nginx.com>
parents: 1312
diff changeset
162 </note>
966
95c3c3bbf1ce Text review.
Egor Nikitin <yegor.nikitin@gmail.com>
parents: 870
diff changeset
163 Usage example:
179
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
164 <example>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
165 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
166 </example>
966
95c3c3bbf1ce Text review.
Egor Nikitin <yegor.nikitin@gmail.com>
parents: 870
diff changeset
167 Here, a client IP address serves as a key.
179
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
168 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
169 <var>$binary_remote_addr</var> variable is used here.
966
95c3c3bbf1ce Text review.
Egor Nikitin <yegor.nikitin@gmail.com>
parents: 870
diff changeset
170 The <var>$remote_addr</var> variable’s size can
95c3c3bbf1ce Text review.
Egor Nikitin <yegor.nikitin@gmail.com>
parents: 870
diff changeset
171 vary from 7 to 15 bytes.
95c3c3bbf1ce Text review.
Egor Nikitin <yegor.nikitin@gmail.com>
parents: 870
diff changeset
172 The stored state occupies either
95c3c3bbf1ce Text review.
Egor Nikitin <yegor.nikitin@gmail.com>
parents: 870
diff changeset
173 32 or 64 bytes of memory on 32-bit platforms and always 64
179
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
174 bytes on 64-bit platforms.
966
95c3c3bbf1ce Text review.
Egor Nikitin <yegor.nikitin@gmail.com>
parents: 870
diff changeset
175 The <var>$binary_remote_addr</var> variable’s size
1699
6c96a644b0b3 Corrected description of $binary_remote_addr and saved state.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 1628
diff changeset
176 is always 4 bytes for IPv4 addresses or 16 bytes for IPv6 addresses.
6c96a644b0b3 Corrected description of $binary_remote_addr and saved state.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 1628
diff changeset
177 The stored state always occupies 32 or 64 bytes
966
95c3c3bbf1ce Text review.
Egor Nikitin <yegor.nikitin@gmail.com>
parents: 870
diff changeset
178 on 32-bit platforms and 64 bytes on 64-bit platforms.
95c3c3bbf1ce Text review.
Egor Nikitin <yegor.nikitin@gmail.com>
parents: 870
diff changeset
179 One megabyte zone can keep about 32 thousand 32-byte states
95c3c3bbf1ce Text review.
Egor Nikitin <yegor.nikitin@gmail.com>
parents: 870
diff changeset
180 or about 16 thousand 64-byte states.
95c3c3bbf1ce Text review.
Egor Nikitin <yegor.nikitin@gmail.com>
parents: 870
diff changeset
181 If the zone storage is exhausted, the server will return the
2013
469aebbd94d0 Limit_req/limit_conn may return not only 503 on failure.
Ruslan Ermilov <ru@nginx.com>
parents: 1699
diff changeset
182 <link id="limit_conn_status">error</link>
469aebbd94d0 Limit_req/limit_conn may return not only 503 on failure.
Ruslan Ermilov <ru@nginx.com>
parents: 1699
diff changeset
183 to all further requests.
179
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
184 </para>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
185
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
186 </directive>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
187
364
bb51d3e17dd0 Style fixed.
Ruslan Ermilov <ru@nginx.com>
parents: 351
diff changeset
188
179
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
189 <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
190 <syntax>
271
4c6d2c614d2c Cleaned up XML tag mess:
Ruslan Ermilov <ru@nginx.com>
parents: 270
diff changeset
191 <value>name</value>
4c6d2c614d2c Cleaned up XML tag mess:
Ruslan Ermilov <ru@nginx.com>
parents: 270
diff changeset
192 <value>$variable</value>
4c6d2c614d2c Cleaned up XML tag mess:
Ruslan Ermilov <ru@nginx.com>
parents: 270
diff changeset
193 <value>size</value></syntax>
179
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
194 <default/>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
195 <context>http</context>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
196
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
197 <para>
1312
91a4eee45eb7 Limit_conn: the limit_zone directive removed from the code.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 966
diff changeset
198 This directive was made obsolete in version 1.1.8
91a4eee45eb7 Limit_conn: the limit_zone directive removed from the code.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 966
diff changeset
199 and was removed in version 1.7.6.
91a4eee45eb7 Limit_conn: the limit_zone directive removed from the code.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 966
diff changeset
200 An equivalent <link id="limit_conn_zone"/> directive
180
9e7d0c9c7eaa Mentioned the compatible "limit_conn_zone" directive syntax for the
Ruslan Ermilov <ru@nginx.com>
parents: 179
diff changeset
201 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
202 <note>
271
4c6d2c614d2c Cleaned up XML tag mess:
Ruslan Ermilov <ru@nginx.com>
parents: 270
diff changeset
203 <literal>limit_conn_zone</literal>
4c6d2c614d2c Cleaned up XML tag mess:
Ruslan Ermilov <ru@nginx.com>
parents: 270
diff changeset
204 <value>$variable</value>
4c6d2c614d2c Cleaned up XML tag mess:
Ruslan Ermilov <ru@nginx.com>
parents: 270
diff changeset
205 <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
206 </note>
179
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
207 </para>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
208
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
209 </directive>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
210
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
211 </section>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
212
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
213 </module>