Mercurial > hg > nginx-site
annotate xml/en/docs/http/ngx_http_limit_req_module.xml @ 3094:f7e9bd7de0f9 default tip
freenginx-1.27.3
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Tue, 13 Aug 2024 17:45:23 +0300 |
parents | 9eadb98ec770 |
children |
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" |
3043
9eadb98ec770
Free nginx: removed commercial version documentation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
2593
diff
changeset
|
13 rev="17"> |
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> |
2593
eeed494bba51
Unified phrases about configuration levels and inheritance.
Ruslan Ermilov <ru@nginx.com>
parents:
2512
diff
changeset
|
120 These directives are inherited from the previous configuration level |
eeed494bba51
Unified phrases about configuration levels and inheritance.
Ruslan Ermilov <ru@nginx.com>
parents:
2512
diff
changeset
|
121 if and only if there are no <literal>limit_req</literal> directives |
eeed494bba51
Unified phrases about configuration levels and inheritance.
Ruslan Ermilov <ru@nginx.com>
parents:
2512
diff
changeset
|
122 defined on the current level. |
1629
7945dac7ad47
Documented multiple limit_req support and inheritance rules.
Ruslan Ermilov <ru@nginx.com>
parents:
1320
diff
changeset
|
123 </para> |
7945dac7ad47
Documented multiple limit_req support and inheritance rules.
Ruslan Ermilov <ru@nginx.com>
parents:
1320
diff
changeset
|
124 |
179
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
125 </directive> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
126 |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
127 |
2400
f86b5961e9b8
Documented the limit_req_dry_run directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2291
diff
changeset
|
128 <directive name="limit_req_dry_run"> |
f86b5961e9b8
Documented the limit_req_dry_run directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2291
diff
changeset
|
129 <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
|
130 <default>off</default> |
2400
f86b5961e9b8
Documented the limit_req_dry_run directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2291
diff
changeset
|
131 <context>http</context> |
f86b5961e9b8
Documented the limit_req_dry_run directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2291
diff
changeset
|
132 <context>server</context> |
f86b5961e9b8
Documented the limit_req_dry_run directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2291
diff
changeset
|
133 <context>location</context> |
f86b5961e9b8
Documented the limit_req_dry_run directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2291
diff
changeset
|
134 <appeared-in>1.17.1</appeared-in> |
f86b5961e9b8
Documented the limit_req_dry_run directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2291
diff
changeset
|
135 |
f86b5961e9b8
Documented the limit_req_dry_run directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2291
diff
changeset
|
136 <para> |
f86b5961e9b8
Documented the limit_req_dry_run directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2291
diff
changeset
|
137 Enables the dry run mode. |
f86b5961e9b8
Documented the limit_req_dry_run directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2291
diff
changeset
|
138 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
|
139 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
|
140 as usual. |
f86b5961e9b8
Documented the limit_req_dry_run directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2291
diff
changeset
|
141 </para> |
f86b5961e9b8
Documented the limit_req_dry_run directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2291
diff
changeset
|
142 |
f86b5961e9b8
Documented the limit_req_dry_run directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2291
diff
changeset
|
143 </directive> |
f86b5961e9b8
Documented the limit_req_dry_run directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2291
diff
changeset
|
144 |
f86b5961e9b8
Documented the limit_req_dry_run directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2291
diff
changeset
|
145 |
179
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
146 <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
|
147 <syntax> |
271 | 148 <literal>info</literal> | |
149 <literal>notice</literal> | | |
150 <literal>warn</literal> | | |
151 <literal>error</literal></syntax> | |
179
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
152 <default>error</default> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
153 <context>http</context> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
154 <context>server</context> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
155 <context>location</context> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
156 <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
|
157 |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
158 <para> |
529
d477ae38c0bd
Clarified on what this module actually limits.
Ruslan Ermilov <ru@nginx.com>
parents:
509
diff
changeset
|
159 Sets the desired logging level |
d477ae38c0bd
Clarified on what this module actually limits.
Ruslan Ermilov <ru@nginx.com>
parents:
509
diff
changeset
|
160 for cases when the server refuses to process requests |
966 | 161 due to rate exceeding, |
529
d477ae38c0bd
Clarified on what this module actually limits.
Ruslan Ermilov <ru@nginx.com>
parents:
509
diff
changeset
|
162 or delays request processing. |
966 | 163 Logging level for delays is one point less than for refusals; for example, |
271 | 164 if “<literal>limit_req_log_level notice</literal>” is specified, |
165 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
|
166 </para> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
167 |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
168 </directive> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
169 |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
170 |
870
6087d3fa6919
The limit_req_status and limit_conn_status directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
816
diff
changeset
|
171 <directive name="limit_req_status"> |
6087d3fa6919
The limit_req_status and limit_conn_status directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
816
diff
changeset
|
172 <syntax><value>code</value></syntax> |
6087d3fa6919
The limit_req_status and limit_conn_status directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
816
diff
changeset
|
173 <default>503</default> |
6087d3fa6919
The limit_req_status and limit_conn_status directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
816
diff
changeset
|
174 <context>http</context> |
6087d3fa6919
The limit_req_status and limit_conn_status directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
816
diff
changeset
|
175 <context>server</context> |
6087d3fa6919
The limit_req_status and limit_conn_status directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
816
diff
changeset
|
176 <context>location</context> |
6087d3fa6919
The limit_req_status and limit_conn_status directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
816
diff
changeset
|
177 <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
|
178 |
6087d3fa6919
The limit_req_status and limit_conn_status directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
816
diff
changeset
|
179 <para> |
966 | 180 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
|
181 </para> |
6087d3fa6919
The limit_req_status and limit_conn_status directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
816
diff
changeset
|
182 |
6087d3fa6919
The limit_req_status and limit_conn_status directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
816
diff
changeset
|
183 </directive> |
6087d3fa6919
The limit_req_status and limit_conn_status directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
816
diff
changeset
|
184 |
6087d3fa6919
The limit_req_status and limit_conn_status directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
816
diff
changeset
|
185 |
179
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
186 <directive name="limit_req_zone"> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
187 <syntax> |
1320
f15a983cac66
Limit conn/req: key is no longer limited to only one variable.
Ruslan Ermilov <ru@nginx.com>
parents:
1144
diff
changeset
|
188 <value>key</value> |
271 | 189 <literal>zone</literal>=<value>name</value>:<value>size</value> |
3043
9eadb98ec770
Free nginx: removed commercial version documentation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
2593
diff
changeset
|
190 <literal>rate</literal>=<value>rate</value></syntax> |
179
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
191 <default/> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
192 <context>http</context> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
193 |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
194 <para> |
966 | 195 Sets parameters for a shared memory zone |
196 that will keep states for various keys. | |
197 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
|
198 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
|
199 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
|
200 <note> |
f15a983cac66
Limit conn/req: key is no longer limited to only one variable.
Ruslan Ermilov <ru@nginx.com>
parents:
1144
diff
changeset
|
201 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
|
202 </note> |
966 | 203 Usage example: |
179
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
204 <example> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
205 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
|
206 </example> |
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 <para> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
210 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
|
211 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
|
212 1 request per second. |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
213 </para> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
214 |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
215 <para> |
966 | 216 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
|
217 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
|
218 <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
|
219 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
|
220 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
|
221 The stored state always occupies |
6c96a644b0b3
Corrected description of $binary_remote_addr and saved state.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
1629
diff
changeset
|
222 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
|
223 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
|
224 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
|
225 </para> |
6e66487c5756
Limit_req: document what happens on zone exhaustion (ticket #1133)
Ruslan Ermilov <ru@nginx.com>
parents:
2013
diff
changeset
|
226 |
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 If the zone storage is exhausted, the least recently used state is removed. |
2512
804bcc58f120
Rephrased sentence in limit_req_zone (trac #1939).
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2495
diff
changeset
|
229 If even after that a new state cannot be created, the request is terminated with |
2014
6e66487c5756
Limit_req: document what happens on zone exhaustion (ticket #1133)
Ruslan Ermilov <ru@nginx.com>
parents:
2013
diff
changeset
|
230 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
|
231 </para> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
232 |
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 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
|
235 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
|
236 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
|
237 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
|
238 </para> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
239 |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
240 </directive> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
241 |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
242 </section> |
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
243 |
2462
63a2a3dc3d63
Documented the $limit_req_status variable.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2449
diff
changeset
|
244 |
63a2a3dc3d63
Documented the $limit_req_status variable.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2449
diff
changeset
|
245 <section id="variables" name="Embedded Variables"> |
63a2a3dc3d63
Documented the $limit_req_status variable.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2449
diff
changeset
|
246 |
63a2a3dc3d63
Documented the $limit_req_status variable.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2449
diff
changeset
|
247 <para> |
63a2a3dc3d63
Documented the $limit_req_status variable.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2449
diff
changeset
|
248 <list type="tag"> |
63a2a3dc3d63
Documented the $limit_req_status variable.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2449
diff
changeset
|
249 |
63a2a3dc3d63
Documented the $limit_req_status variable.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2449
diff
changeset
|
250 <tag-name id="var_limit_req_status"><var>$limit_req_status</var></tag-name> |
63a2a3dc3d63
Documented the $limit_req_status variable.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2449
diff
changeset
|
251 <tag-desc> |
63a2a3dc3d63
Documented the $limit_req_status variable.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2449
diff
changeset
|
252 keeps the result of limiting the request processing rate (1.17.6): |
63a2a3dc3d63
Documented the $limit_req_status variable.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2449
diff
changeset
|
253 <literal>PASSED</literal>, |
63a2a3dc3d63
Documented the $limit_req_status variable.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2449
diff
changeset
|
254 <literal>DELAYED</literal>, |
63a2a3dc3d63
Documented the $limit_req_status variable.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2449
diff
changeset
|
255 <literal>REJECTED</literal>, |
63a2a3dc3d63
Documented the $limit_req_status variable.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2449
diff
changeset
|
256 <literal>DELAYED_DRY_RUN</literal>, or |
63a2a3dc3d63
Documented the $limit_req_status variable.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2449
diff
changeset
|
257 <literal>REJECTED_DRY_RUN</literal> |
63a2a3dc3d63
Documented the $limit_req_status variable.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2449
diff
changeset
|
258 </tag-desc> |
63a2a3dc3d63
Documented the $limit_req_status variable.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2449
diff
changeset
|
259 |
63a2a3dc3d63
Documented the $limit_req_status variable.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2449
diff
changeset
|
260 </list> |
63a2a3dc3d63
Documented the $limit_req_status variable.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2449
diff
changeset
|
261 </para> |
63a2a3dc3d63
Documented the $limit_req_status variable.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2449
diff
changeset
|
262 |
63a2a3dc3d63
Documented the $limit_req_status variable.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2449
diff
changeset
|
263 </section> |
63a2a3dc3d63
Documented the $limit_req_status variable.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2449
diff
changeset
|
264 |
179
8cc01e2179a9
- Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
265 </module> |