Mercurial > hg > nginx-site
annotate xml/en/docs/http/ngx_http_limit_req_module.xml @ 2454:253641e268a8
Added js_requests.js example in njs.
author | Yaroslav Zhuravlev <yar@nginx.com> |
---|---|
date | Thu, 31 Oct 2019 15:33:19 +0300 |
parents | 384211f17f5a |
children | 63a2a3dc3d63 |
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" |
2449
384211f17f5a
Fixed default value for limit_req_dry_run.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2400
diff
changeset
|
13 rev="12"> |
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>] | |
2291
3294470932c5
Documented the "delay" parameter for limit_req.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2230
diff
changeset
|
56 [<literal>nodelay</literal> | |
3294470932c5
Documented the "delay" parameter for limit_req.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2230
diff
changeset
|
57 <literal>delay</literal>=<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 | 64 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
|
65 and the maximum burst size of requests. |
966 | 66 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
|
67 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
|
68 at a defined rate. |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
69 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
|
70 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
|
71 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
|
72 <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
|
73 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
|
74 For example, the directives |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
75 <example> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
76 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
|
77 |
351
a4fa80755eab
Consistently strip initial offset in examples.
Ruslan Ermilov <ru@nginx.com>
parents:
288
diff
changeset
|
78 server { |
a4fa80755eab
Consistently strip initial offset in examples.
Ruslan Ermilov <ru@nginx.com>
parents:
288
diff
changeset
|
79 location /search/ { |
a4fa80755eab
Consistently strip initial offset in examples.
Ruslan Ermilov <ru@nginx.com>
parents:
288
diff
changeset
|
80 limit_req zone=one burst=5; |
a4fa80755eab
Consistently strip initial offset in examples.
Ruslan Ermilov <ru@nginx.com>
parents:
288
diff
changeset
|
81 } |
179
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
82 </example> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
83 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
|
84 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
|
85 </para> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
86 |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
87 <para> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
88 If delaying of excessive requests while requests are being limited is not |
271 | 89 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
|
90 <example> |
351
a4fa80755eab
Consistently strip initial offset in examples.
Ruslan Ermilov <ru@nginx.com>
parents:
288
diff
changeset
|
91 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
|
92 </example> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
93 </para> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
94 |
2291
3294470932c5
Documented the "delay" parameter for limit_req.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2230
diff
changeset
|
95 <para id="limit_req_delay"> |
3294470932c5
Documented the "delay" parameter for limit_req.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2230
diff
changeset
|
96 The <literal>delay</literal> parameter (1.15.7) specifies a limit |
3294470932c5
Documented the "delay" parameter for limit_req.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2230
diff
changeset
|
97 at which excessive requests become delayed. |
3294470932c5
Documented the "delay" parameter for limit_req.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2230
diff
changeset
|
98 Default value is zero, i.e. all excessive requests are delayed. |
3294470932c5
Documented the "delay" parameter for limit_req.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2230
diff
changeset
|
99 </para> |
3294470932c5
Documented the "delay" parameter for limit_req.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2230
diff
changeset
|
100 |
1629
7945dac7ad47
Documented multiple limit_req support and inheritance rules.
Ruslan Ermilov <ru@nginx.com>
parents:
1320
diff
changeset
|
101 <para> |
7945dac7ad47
Documented multiple limit_req support and inheritance rules.
Ruslan Ermilov <ru@nginx.com>
parents:
1320
diff
changeset
|
102 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
|
103 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
|
104 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
|
105 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
|
106 <example> |
7945dac7ad47
Documented multiple limit_req support and inheritance rules.
Ruslan Ermilov <ru@nginx.com>
parents:
1320
diff
changeset
|
107 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
|
108 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
|
109 |
7945dac7ad47
Documented multiple limit_req support and inheritance rules.
Ruslan Ermilov <ru@nginx.com>
parents:
1320
diff
changeset
|
110 server { |
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 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
|
113 limit_req zone=perserver burst=10; |
7945dac7ad47
Documented multiple limit_req support and inheritance rules.
Ruslan Ermilov <ru@nginx.com>
parents:
1320
diff
changeset
|
114 } |
7945dac7ad47
Documented multiple limit_req support and inheritance rules.
Ruslan Ermilov <ru@nginx.com>
parents:
1320
diff
changeset
|
115 </example> |
7945dac7ad47
Documented multiple limit_req support and inheritance rules.
Ruslan Ermilov <ru@nginx.com>
parents:
1320
diff
changeset
|
116 |
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 |
7945dac7ad47
Documented multiple limit_req support and inheritance rules.
Ruslan Ermilov <ru@nginx.com>
parents:
1320
diff
changeset
|
119 <para> |
7945dac7ad47
Documented multiple limit_req support and inheritance rules.
Ruslan Ermilov <ru@nginx.com>
parents:
1320
diff
changeset
|
120 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
|
121 only if there are no |
7945dac7ad47
Documented multiple limit_req support and inheritance rules.
Ruslan Ermilov <ru@nginx.com>
parents:
1320
diff
changeset
|
122 <literal>limit_req</literal> |
7945dac7ad47
Documented multiple limit_req support and inheritance rules.
Ruslan Ermilov <ru@nginx.com>
parents:
1320
diff
changeset
|
123 directives on the current level. |
7945dac7ad47
Documented multiple limit_req support and inheritance rules.
Ruslan Ermilov <ru@nginx.com>
parents:
1320
diff
changeset
|
124 </para> |
7945dac7ad47
Documented multiple limit_req support and inheritance rules.
Ruslan Ermilov <ru@nginx.com>
parents:
1320
diff
changeset
|
125 |
179
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
126 </directive> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
127 |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
128 |
2400
f86b5961e9b8
Documented the limit_req_dry_run directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2291
diff
changeset
|
129 <directive name="limit_req_dry_run"> |
f86b5961e9b8
Documented the limit_req_dry_run directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2291
diff
changeset
|
130 <syntax><literal>on</literal> | <literal>off</literal></syntax> |
2449
384211f17f5a
Fixed default value for limit_req_dry_run.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2400
diff
changeset
|
131 <default>off</default> |
2400
f86b5961e9b8
Documented the limit_req_dry_run directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2291
diff
changeset
|
132 <context>http</context> |
f86b5961e9b8
Documented the limit_req_dry_run directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2291
diff
changeset
|
133 <context>server</context> |
f86b5961e9b8
Documented the limit_req_dry_run directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2291
diff
changeset
|
134 <context>location</context> |
f86b5961e9b8
Documented the limit_req_dry_run directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2291
diff
changeset
|
135 <appeared-in>1.17.1</appeared-in> |
f86b5961e9b8
Documented the limit_req_dry_run directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2291
diff
changeset
|
136 |
f86b5961e9b8
Documented the limit_req_dry_run directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2291
diff
changeset
|
137 <para> |
f86b5961e9b8
Documented the limit_req_dry_run directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2291
diff
changeset
|
138 Enables the dry run mode. |
f86b5961e9b8
Documented the limit_req_dry_run directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2291
diff
changeset
|
139 In this mode, requests processing rate is not limited, however, |
f86b5961e9b8
Documented the limit_req_dry_run directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2291
diff
changeset
|
140 in the shared memory zone, the number of excessive requests is accounted |
f86b5961e9b8
Documented the limit_req_dry_run directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2291
diff
changeset
|
141 as usual. |
f86b5961e9b8
Documented the limit_req_dry_run directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2291
diff
changeset
|
142 </para> |
f86b5961e9b8
Documented the limit_req_dry_run directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2291
diff
changeset
|
143 |
f86b5961e9b8
Documented the limit_req_dry_run directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2291
diff
changeset
|
144 </directive> |
f86b5961e9b8
Documented the limit_req_dry_run directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2291
diff
changeset
|
145 |
f86b5961e9b8
Documented the limit_req_dry_run directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2291
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_req_log_level"> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
148 <syntax> |
271 | 149 <literal>info</literal> | |
150 <literal>notice</literal> | | |
151 <literal>warn</literal> | | |
152 <literal>error</literal></syntax> | |
179
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
153 <default>error</default> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
154 <context>http</context> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
155 <context>server</context> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
156 <context>location</context> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
157 <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
|
158 |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
159 <para> |
529
d477ae38c0bd
Clarified on what this module actually limits.
Ruslan Ermilov <ru@nginx.com>
parents:
509
diff
changeset
|
160 Sets the desired logging level |
d477ae38c0bd
Clarified on what this module actually limits.
Ruslan Ermilov <ru@nginx.com>
parents:
509
diff
changeset
|
161 for cases when the server refuses to process requests |
966 | 162 due to rate exceeding, |
529
d477ae38c0bd
Clarified on what this module actually limits.
Ruslan Ermilov <ru@nginx.com>
parents:
509
diff
changeset
|
163 or delays request processing. |
966 | 164 Logging level for delays is one point less than for refusals; for example, |
271 | 165 if “<literal>limit_req_log_level notice</literal>” is specified, |
166 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
|
167 </para> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
168 |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
169 </directive> |
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 |
870
6087d3fa6919
The limit_req_status and limit_conn_status directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
816
diff
changeset
|
172 <directive name="limit_req_status"> |
6087d3fa6919
The limit_req_status and limit_conn_status directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
816
diff
changeset
|
173 <syntax><value>code</value></syntax> |
6087d3fa6919
The limit_req_status and limit_conn_status directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
816
diff
changeset
|
174 <default>503</default> |
6087d3fa6919
The limit_req_status and limit_conn_status directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
816
diff
changeset
|
175 <context>http</context> |
6087d3fa6919
The limit_req_status and limit_conn_status directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
816
diff
changeset
|
176 <context>server</context> |
6087d3fa6919
The limit_req_status and limit_conn_status directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
816
diff
changeset
|
177 <context>location</context> |
6087d3fa6919
The limit_req_status and limit_conn_status directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
816
diff
changeset
|
178 <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
|
179 |
6087d3fa6919
The limit_req_status and limit_conn_status directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
816
diff
changeset
|
180 <para> |
966 | 181 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
|
182 </para> |
6087d3fa6919
The limit_req_status and limit_conn_status directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
816
diff
changeset
|
183 |
6087d3fa6919
The limit_req_status and limit_conn_status directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
816
diff
changeset
|
184 </directive> |
6087d3fa6919
The limit_req_status and limit_conn_status directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
816
diff
changeset
|
185 |
6087d3fa6919
The limit_req_status and limit_conn_status directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
816
diff
changeset
|
186 |
179
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
187 <directive name="limit_req_zone"> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
188 <syntax> |
1320
f15a983cac66
Limit conn/req: key is no longer limited to only one variable.
Ruslan Ermilov <ru@nginx.com>
parents:
1144
diff
changeset
|
189 <value>key</value> |
271 | 190 <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
|
191 <literal>rate</literal>=<value>rate</value> |
283b1e67eaa6
Updated docs for the upcoming NGINX Plus release.
Ruslan Ermilov <ru@nginx.com>
parents:
2014
diff
changeset
|
192 [<literal>sync</literal>]</syntax> |
179
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
193 <default/> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
194 <context>http</context> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
195 |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
196 <para> |
966 | 197 Sets parameters for a shared memory zone |
198 that will keep states for various keys. | |
199 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
|
200 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
|
201 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
|
202 <note> |
f15a983cac66
Limit conn/req: key is no longer limited to only one variable.
Ruslan Ermilov <ru@nginx.com>
parents:
1144
diff
changeset
|
203 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
|
204 </note> |
966 | 205 Usage example: |
179
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
206 <example> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
207 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
|
208 </example> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
209 </para> |
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 <para> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
212 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
|
213 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
|
214 1 request per second. |
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 |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
217 <para> |
966 | 218 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
|
219 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
|
220 <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
|
221 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
|
222 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
|
223 The stored state always occupies |
6c96a644b0b3
Corrected description of $binary_remote_addr and saved state.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
1629
diff
changeset
|
224 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
|
225 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
|
226 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
|
227 </para> |
6e66487c5756
Limit_req: document what happens on zone exhaustion (ticket #1133)
Ruslan Ermilov <ru@nginx.com>
parents:
2013
diff
changeset
|
228 |
6e66487c5756
Limit_req: document what happens on zone exhaustion (ticket #1133)
Ruslan Ermilov <ru@nginx.com>
parents:
2013
diff
changeset
|
229 <para> |
6e66487c5756
Limit_req: document what happens on zone exhaustion (ticket #1133)
Ruslan Ermilov <ru@nginx.com>
parents:
2013
diff
changeset
|
230 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
|
231 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
|
232 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
|
233 </para> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
234 |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
235 <para> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
236 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
|
237 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
|
238 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
|
239 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
|
240 </para> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
241 |
2230
283b1e67eaa6
Updated docs for the upcoming NGINX Plus release.
Ruslan Ermilov <ru@nginx.com>
parents:
2014
diff
changeset
|
242 <para id="limit_req_zone_sync"> |
283b1e67eaa6
Updated docs for the upcoming NGINX Plus release.
Ruslan Ermilov <ru@nginx.com>
parents:
2014
diff
changeset
|
243 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
|
244 <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
|
245 of the shared memory zone. |
283b1e67eaa6
Updated docs for the upcoming NGINX Plus release.
Ruslan Ermilov <ru@nginx.com>
parents:
2014
diff
changeset
|
246 <note> |
283b1e67eaa6
Updated docs for the upcoming NGINX Plus release.
Ruslan Ermilov <ru@nginx.com>
parents:
2014
diff
changeset
|
247 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
|
248 <commercial_version>commercial subscription</commercial_version>. |
283b1e67eaa6
Updated docs for the upcoming NGINX Plus release.
Ruslan Ermilov <ru@nginx.com>
parents:
2014
diff
changeset
|
249 </note> |
283b1e67eaa6
Updated docs for the upcoming NGINX Plus release.
Ruslan Ermilov <ru@nginx.com>
parents:
2014
diff
changeset
|
250 </para> |
283b1e67eaa6
Updated docs for the upcoming NGINX Plus release.
Ruslan Ermilov <ru@nginx.com>
parents:
2014
diff
changeset
|
251 |
179
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
252 </directive> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
253 |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
254 </section> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
255 |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
256 </module> |