Mercurial > hg > nginx-site
annotate xml/en/docs/http/ngx_http_limit_req_module.xml @ 2230:283b1e67eaa6
Updated docs for the upcoming NGINX Plus release.
author | Ruslan Ermilov <ru@nginx.com> |
---|---|
date | Thu, 30 Aug 2018 22:53:18 +0300 |
parents | 6e66487c5756 |
children | 3294470932c5 |
rev | line source |
---|---|
222
bfe3eff81d04
Removed redundant encoding specification.
Ruslan Ermilov <ru@nginx.com>
parents:
179
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_req_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_req_module.html" |
589 | 12 lang="en" |
2230
283b1e67eaa6
Updated docs for the upcoming NGINX Plus release.
Ruslan Ermilov <ru@nginx.com>
parents:
2014
diff
changeset
|
13 rev="9"> |
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 | 18 The <literal>ngx_http_limit_req_module</literal> module (0.7.21) is used |
19 to limit the request processing rate per a defined key, | |
529
d477ae38c0bd
Clarified on what this module actually limits.
Ruslan Ermilov <ru@nginx.com>
parents:
509
diff
changeset
|
20 in particular, the processing rate of requests coming |
179
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
21 from a single IP address. |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
22 The limitation is done using the “leaky bucket” method. |
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 |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
25 </section> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
26 |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
27 |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
28 <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
|
29 |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
30 <para> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
31 <example> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
32 http { |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
33 limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s; |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
34 |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
35 ... |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
36 |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
37 server { |
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 location /search/ { |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
42 limit_req zone=one burst=5; |
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 </example> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
45 </para> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
46 |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
47 </section> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
48 |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
49 |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
50 <section id="directives" name="Directives"> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
51 |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
52 <directive name="limit_req"> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
53 <syntax> |
271 | 54 <literal>zone</literal>=<value>name</value> |
55 [<literal>burst</literal>=<value>number</value>] | |
56 [<literal>nodelay</literal>]</syntax> | |
179
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
57 <default/> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
58 <context>http</context> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
59 <context>server</context> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
60 <context>location</context> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
61 |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
62 <para> |
966 | 63 Sets the shared memory zone |
816
c711c50bdcf4
limit_req: clarified the description of the burst= parameter.
Ruslan Ermilov <ru@nginx.com>
parents:
589
diff
changeset
|
64 and the maximum burst size of requests. |
966 | 65 If the requests rate exceeds the rate configured for a zone, |
816
c711c50bdcf4
limit_req: clarified the description of the burst= parameter.
Ruslan Ermilov <ru@nginx.com>
parents:
589
diff
changeset
|
66 their processing is delayed such that requests are processed |
179
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
67 at a defined rate. |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
68 Excessive requests are delayed until their number exceeds the |
816
c711c50bdcf4
limit_req: clarified the description of the burst= parameter.
Ruslan Ermilov <ru@nginx.com>
parents:
589
diff
changeset
|
69 maximum burst size |
2013
469aebbd94d0
Limit_req/limit_conn may return not only 503 on failure.
Ruslan Ermilov <ru@nginx.com>
parents:
1699
diff
changeset
|
70 in which case the request is terminated with an |
469aebbd94d0
Limit_req/limit_conn may return not only 503 on failure.
Ruslan Ermilov <ru@nginx.com>
parents:
1699
diff
changeset
|
71 <link id="limit_req_status">error</link>. |
816
c711c50bdcf4
limit_req: clarified the description of the burst= parameter.
Ruslan Ermilov <ru@nginx.com>
parents:
589
diff
changeset
|
72 By default, the maximum burst size is equal to zero. |
179
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
73 For example, the directives |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
74 <example> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
75 limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s; |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
76 |
351
a4fa80755eab
Consistently strip initial offset in examples.
Ruslan Ermilov <ru@nginx.com>
parents:
288
diff
changeset
|
77 server { |
a4fa80755eab
Consistently strip initial offset in examples.
Ruslan Ermilov <ru@nginx.com>
parents:
288
diff
changeset
|
78 location /search/ { |
a4fa80755eab
Consistently strip initial offset in examples.
Ruslan Ermilov <ru@nginx.com>
parents:
288
diff
changeset
|
79 limit_req zone=one burst=5; |
a4fa80755eab
Consistently strip initial offset in examples.
Ruslan Ermilov <ru@nginx.com>
parents:
288
diff
changeset
|
80 } |
179
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
81 </example> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
82 allow not more than 1 request per second at an average, |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
83 with bursts not exceeding 5 requests. |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
84 </para> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
85 |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
86 <para> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
87 If delaying of excessive requests while requests are being limited is not |
271 | 88 desired, the parameter <literal>nodelay</literal> should be used: |
179
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
89 <example> |
351
a4fa80755eab
Consistently strip initial offset in examples.
Ruslan Ermilov <ru@nginx.com>
parents:
288
diff
changeset
|
90 limit_req zone=one burst=5 nodelay; |
179
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
91 </example> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
92 </para> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
93 |
1629
7945dac7ad47
Documented multiple limit_req support and inheritance rules.
Ruslan Ermilov <ru@nginx.com>
parents:
1320
diff
changeset
|
94 <para> |
7945dac7ad47
Documented multiple limit_req support and inheritance rules.
Ruslan Ermilov <ru@nginx.com>
parents:
1320
diff
changeset
|
95 There could be several <literal>limit_req</literal> directives. |
7945dac7ad47
Documented multiple limit_req support and inheritance rules.
Ruslan Ermilov <ru@nginx.com>
parents:
1320
diff
changeset
|
96 For example, the following configuration will limit the processing rate |
7945dac7ad47
Documented multiple limit_req support and inheritance rules.
Ruslan Ermilov <ru@nginx.com>
parents:
1320
diff
changeset
|
97 of requests coming from a single IP address and, at the same time, |
7945dac7ad47
Documented multiple limit_req support and inheritance rules.
Ruslan Ermilov <ru@nginx.com>
parents:
1320
diff
changeset
|
98 the request processing rate by the virtual server: |
7945dac7ad47
Documented multiple limit_req support and inheritance rules.
Ruslan Ermilov <ru@nginx.com>
parents:
1320
diff
changeset
|
99 <example> |
7945dac7ad47
Documented multiple limit_req support and inheritance rules.
Ruslan Ermilov <ru@nginx.com>
parents:
1320
diff
changeset
|
100 limit_req_zone $binary_remote_addr zone=perip:10m rate=1r/s; |
7945dac7ad47
Documented multiple limit_req support and inheritance rules.
Ruslan Ermilov <ru@nginx.com>
parents:
1320
diff
changeset
|
101 limit_req_zone $server_name zone=perserver:10m rate=10r/s; |
7945dac7ad47
Documented multiple limit_req support and inheritance rules.
Ruslan Ermilov <ru@nginx.com>
parents:
1320
diff
changeset
|
102 |
7945dac7ad47
Documented multiple limit_req support and inheritance rules.
Ruslan Ermilov <ru@nginx.com>
parents:
1320
diff
changeset
|
103 server { |
7945dac7ad47
Documented multiple limit_req support and inheritance rules.
Ruslan Ermilov <ru@nginx.com>
parents:
1320
diff
changeset
|
104 ... |
7945dac7ad47
Documented multiple limit_req support and inheritance rules.
Ruslan Ermilov <ru@nginx.com>
parents:
1320
diff
changeset
|
105 limit_req zone=perip burst=5 nodelay; |
7945dac7ad47
Documented multiple limit_req support and inheritance rules.
Ruslan Ermilov <ru@nginx.com>
parents:
1320
diff
changeset
|
106 limit_req zone=perserver burst=10; |
7945dac7ad47
Documented multiple limit_req support and inheritance rules.
Ruslan Ermilov <ru@nginx.com>
parents:
1320
diff
changeset
|
107 } |
7945dac7ad47
Documented multiple limit_req support and inheritance rules.
Ruslan Ermilov <ru@nginx.com>
parents:
1320
diff
changeset
|
108 </example> |
7945dac7ad47
Documented multiple limit_req support and inheritance rules.
Ruslan Ermilov <ru@nginx.com>
parents:
1320
diff
changeset
|
109 |
7945dac7ad47
Documented multiple limit_req support and inheritance rules.
Ruslan Ermilov <ru@nginx.com>
parents:
1320
diff
changeset
|
110 </para> |
7945dac7ad47
Documented multiple limit_req support and inheritance rules.
Ruslan Ermilov <ru@nginx.com>
parents:
1320
diff
changeset
|
111 |
7945dac7ad47
Documented multiple limit_req support and inheritance rules.
Ruslan Ermilov <ru@nginx.com>
parents:
1320
diff
changeset
|
112 <para> |
7945dac7ad47
Documented multiple limit_req support and inheritance rules.
Ruslan Ermilov <ru@nginx.com>
parents:
1320
diff
changeset
|
113 These directives are inherited from the previous level if and |
7945dac7ad47
Documented multiple limit_req support and inheritance rules.
Ruslan Ermilov <ru@nginx.com>
parents:
1320
diff
changeset
|
114 only if there are no |
7945dac7ad47
Documented multiple limit_req support and inheritance rules.
Ruslan Ermilov <ru@nginx.com>
parents:
1320
diff
changeset
|
115 <literal>limit_req</literal> |
7945dac7ad47
Documented multiple limit_req support and inheritance rules.
Ruslan Ermilov <ru@nginx.com>
parents:
1320
diff
changeset
|
116 directives on the current level. |
7945dac7ad47
Documented multiple limit_req support and inheritance rules.
Ruslan Ermilov <ru@nginx.com>
parents:
1320
diff
changeset
|
117 </para> |
7945dac7ad47
Documented multiple limit_req support and inheritance rules.
Ruslan Ermilov <ru@nginx.com>
parents:
1320
diff
changeset
|
118 |
179
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
119 </directive> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
120 |
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 <directive name="limit_req_log_level"> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
123 <syntax> |
271 | 124 <literal>info</literal> | |
125 <literal>notice</literal> | | |
126 <literal>warn</literal> | | |
127 <literal>error</literal></syntax> | |
179
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
128 <default>error</default> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
129 <context>http</context> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
130 <context>server</context> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
131 <context>location</context> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
132 <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
|
133 |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
134 <para> |
529
d477ae38c0bd
Clarified on what this module actually limits.
Ruslan Ermilov <ru@nginx.com>
parents:
509
diff
changeset
|
135 Sets the desired logging level |
d477ae38c0bd
Clarified on what this module actually limits.
Ruslan Ermilov <ru@nginx.com>
parents:
509
diff
changeset
|
136 for cases when the server refuses to process requests |
966 | 137 due to rate exceeding, |
529
d477ae38c0bd
Clarified on what this module actually limits.
Ruslan Ermilov <ru@nginx.com>
parents:
509
diff
changeset
|
138 or delays request processing. |
966 | 139 Logging level for delays is one point less than for refusals; for example, |
271 | 140 if “<literal>limit_req_log_level notice</literal>” is specified, |
141 delays are logged with the <literal>info</literal> level. | |
179
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
142 </para> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
143 |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
144 </directive> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
145 |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
146 |
870
6087d3fa6919
The limit_req_status and limit_conn_status directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
816
diff
changeset
|
147 <directive name="limit_req_status"> |
6087d3fa6919
The limit_req_status and limit_conn_status directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
816
diff
changeset
|
148 <syntax><value>code</value></syntax> |
6087d3fa6919
The limit_req_status and limit_conn_status directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
816
diff
changeset
|
149 <default>503</default> |
6087d3fa6919
The limit_req_status and limit_conn_status directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
816
diff
changeset
|
150 <context>http</context> |
6087d3fa6919
The limit_req_status and limit_conn_status directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
816
diff
changeset
|
151 <context>server</context> |
6087d3fa6919
The limit_req_status and limit_conn_status directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
816
diff
changeset
|
152 <context>location</context> |
6087d3fa6919
The limit_req_status and limit_conn_status directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
816
diff
changeset
|
153 <appeared-in>1.3.15</appeared-in> |
6087d3fa6919
The limit_req_status and limit_conn_status directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
816
diff
changeset
|
154 |
6087d3fa6919
The limit_req_status and limit_conn_status directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
816
diff
changeset
|
155 <para> |
966 | 156 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:
816
diff
changeset
|
157 </para> |
6087d3fa6919
The limit_req_status and limit_conn_status directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
816
diff
changeset
|
158 |
6087d3fa6919
The limit_req_status and limit_conn_status directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
816
diff
changeset
|
159 </directive> |
6087d3fa6919
The limit_req_status and limit_conn_status directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
816
diff
changeset
|
160 |
6087d3fa6919
The limit_req_status and limit_conn_status directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
816
diff
changeset
|
161 |
179
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
162 <directive name="limit_req_zone"> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
163 <syntax> |
1320
f15a983cac66
Limit conn/req: key is no longer limited to only one variable.
Ruslan Ermilov <ru@nginx.com>
parents:
1144
diff
changeset
|
164 <value>key</value> |
271 | 165 <literal>zone</literal>=<value>name</value>:<value>size</value> |
2230
283b1e67eaa6
Updated docs for the upcoming NGINX Plus release.
Ruslan Ermilov <ru@nginx.com>
parents:
2014
diff
changeset
|
166 <literal>rate</literal>=<value>rate</value> |
283b1e67eaa6
Updated docs for the upcoming NGINX Plus release.
Ruslan Ermilov <ru@nginx.com>
parents:
2014
diff
changeset
|
167 [<literal>sync</literal>]</syntax> |
179
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
168 <default/> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
169 <context>http</context> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
170 |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
171 <para> |
966 | 172 Sets parameters for a shared memory zone |
173 that will keep states for various keys. | |
174 In particular, the state stores the current number of excessive requests. | |
1320
f15a983cac66
Limit conn/req: key is no longer limited to only one variable.
Ruslan Ermilov <ru@nginx.com>
parents:
1144
diff
changeset
|
175 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:
1144
diff
changeset
|
176 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:
1144
diff
changeset
|
177 <note> |
f15a983cac66
Limit conn/req: key is no longer limited to only one variable.
Ruslan Ermilov <ru@nginx.com>
parents:
1144
diff
changeset
|
178 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:
1144
diff
changeset
|
179 </note> |
966 | 180 Usage example: |
179
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
181 <example> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
182 limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s; |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
183 </example> |
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 <para> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
187 Here, the states are kept in a 10 megabyte zone “one”, and an |
529
d477ae38c0bd
Clarified on what this module actually limits.
Ruslan Ermilov <ru@nginx.com>
parents:
509
diff
changeset
|
188 average request processing rate for this zone cannot exceed |
179
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
189 1 request per second. |
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 |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
192 <para> |
966 | 193 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
|
194 Note that instead of <var>$remote_addr</var>, the |
1699
6c96a644b0b3
Corrected description of $binary_remote_addr and saved state.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
1629
diff
changeset
|
195 <var>$binary_remote_addr</var> variable is used here. |
6c96a644b0b3
Corrected description of $binary_remote_addr and saved state.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
1629
diff
changeset
|
196 The <var>$binary_remote_addr</var> variable’s size |
6c96a644b0b3
Corrected description of $binary_remote_addr and saved state.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
1629
diff
changeset
|
197 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:
1629
diff
changeset
|
198 The stored state always occupies |
6c96a644b0b3
Corrected description of $binary_remote_addr and saved state.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
1629
diff
changeset
|
199 64 bytes on 32-bit platforms and 128 bytes on 64-bit platforms. |
6c96a644b0b3
Corrected description of $binary_remote_addr and saved state.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
1629
diff
changeset
|
200 One megabyte zone can keep about 16 thousand 64-byte states |
6c96a644b0b3
Corrected description of $binary_remote_addr and saved state.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
1629
diff
changeset
|
201 or about 8 thousand 128-byte states. |
2014
6e66487c5756
Limit_req: document what happens on zone exhaustion (ticket #1133)
Ruslan Ermilov <ru@nginx.com>
parents:
2013
diff
changeset
|
202 </para> |
6e66487c5756
Limit_req: document what happens on zone exhaustion (ticket #1133)
Ruslan Ermilov <ru@nginx.com>
parents:
2013
diff
changeset
|
203 |
6e66487c5756
Limit_req: document what happens on zone exhaustion (ticket #1133)
Ruslan Ermilov <ru@nginx.com>
parents:
2013
diff
changeset
|
204 <para> |
6e66487c5756
Limit_req: document what happens on zone exhaustion (ticket #1133)
Ruslan Ermilov <ru@nginx.com>
parents:
2013
diff
changeset
|
205 If the zone storage is exhausted, the least recently used state is removed. |
6e66487c5756
Limit_req: document what happens on zone exhaustion (ticket #1133)
Ruslan Ermilov <ru@nginx.com>
parents:
2013
diff
changeset
|
206 Even if after that a new state cannot be created, the request is terminated with |
6e66487c5756
Limit_req: document what happens on zone exhaustion (ticket #1133)
Ruslan Ermilov <ru@nginx.com>
parents:
2013
diff
changeset
|
207 an <link id="limit_req_status">error</link>. |
179
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
208 </para> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
209 |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
210 <para> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
211 The rate is specified in requests per second (r/s). |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
212 If a rate of less than one request per second is desired, |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
213 it is specified in request per minute (r/m). |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
214 For example, half-request per second is 30r/m. |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
215 </para> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
216 |
2230
283b1e67eaa6
Updated docs for the upcoming NGINX Plus release.
Ruslan Ermilov <ru@nginx.com>
parents:
2014
diff
changeset
|
217 <para id="limit_req_zone_sync"> |
283b1e67eaa6
Updated docs for the upcoming NGINX Plus release.
Ruslan Ermilov <ru@nginx.com>
parents:
2014
diff
changeset
|
218 The <literal>sync</literal> parameter (1.15.3) enables |
283b1e67eaa6
Updated docs for the upcoming NGINX Plus release.
Ruslan Ermilov <ru@nginx.com>
parents:
2014
diff
changeset
|
219 <link doc="../stream/ngx_stream_zone_sync_module.xml" id="zone_sync">synchronization</link> |
283b1e67eaa6
Updated docs for the upcoming NGINX Plus release.
Ruslan Ermilov <ru@nginx.com>
parents:
2014
diff
changeset
|
220 of the shared memory zone. |
283b1e67eaa6
Updated docs for the upcoming NGINX Plus release.
Ruslan Ermilov <ru@nginx.com>
parents:
2014
diff
changeset
|
221 <note> |
283b1e67eaa6
Updated docs for the upcoming NGINX Plus release.
Ruslan Ermilov <ru@nginx.com>
parents:
2014
diff
changeset
|
222 The <literal>sync</literal> parameter is available as part of our |
283b1e67eaa6
Updated docs for the upcoming NGINX Plus release.
Ruslan Ermilov <ru@nginx.com>
parents:
2014
diff
changeset
|
223 <commercial_version>commercial subscription</commercial_version>. |
283b1e67eaa6
Updated docs for the upcoming NGINX Plus release.
Ruslan Ermilov <ru@nginx.com>
parents:
2014
diff
changeset
|
224 </note> |
283b1e67eaa6
Updated docs for the upcoming NGINX Plus release.
Ruslan Ermilov <ru@nginx.com>
parents:
2014
diff
changeset
|
225 </para> |
283b1e67eaa6
Updated docs for the upcoming NGINX Plus release.
Ruslan Ermilov <ru@nginx.com>
parents:
2014
diff
changeset
|
226 |
179
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
227 </directive> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
228 |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
229 </section> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
230 |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
231 </module> |