annotate xml/en/docs/http/ngx_http_limit_req_module.xml @ 1878:127ae107e5a9

Removed clause about shared memory and Windows versions with ASLR. Starting with nginx 1.9.0 shared memory can be used on Windows versions with address space layout randomization.
author Maxim Dounin <mdounin@mdounin.ru>
date Mon, 26 Dec 2016 19:38:06 +0300
parents 6c96a644b0b3
children 469aebbd94d0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
222
bfe3eff81d04 Removed redundant encoding specification.
Ruslan Ermilov <ru@nginx.com>
parents: 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
764fbac1b8b4 Added document revision.
Ruslan Ermilov <ru@nginx.com>
parents: 580
diff changeset
12 lang="en"
1699
6c96a644b0b3 Corrected description of $binary_remote_addr and saved state.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 1629
diff changeset
13 rev="6">
179
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
14
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
15 <section id="summary">
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
16
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
17 <para>
966
95c3c3bbf1ce Text review.
Egor Nikitin <yegor.nikitin@gmail.com>
parents: 870
diff changeset
18 The <literal>ngx_http_limit_req_module</literal> module (0.7.21) is used
95c3c3bbf1ce Text review.
Egor Nikitin <yegor.nikitin@gmail.com>
parents: 870
diff changeset
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
4c6d2c614d2c Cleaned up XML tag mess:
Ruslan Ermilov <ru@nginx.com>
parents: 270
diff changeset
54 <literal>zone</literal>=<value>name</value>
4c6d2c614d2c Cleaned up XML tag mess:
Ruslan Ermilov <ru@nginx.com>
parents: 270
diff changeset
55 [<literal>burst</literal>=<value>number</value>]
4c6d2c614d2c Cleaned up XML tag mess:
Ruslan Ermilov <ru@nginx.com>
parents: 270
diff changeset
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
95c3c3bbf1ce Text review.
Egor Nikitin <yegor.nikitin@gmail.com>
parents: 870
diff changeset
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
95c3c3bbf1ce Text review.
Egor Nikitin <yegor.nikitin@gmail.com>
parents: 870
diff changeset
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
c711c50bdcf4 limit_req: clarified the description of the burst= parameter.
Ruslan Ermilov <ru@nginx.com>
parents: 589
diff changeset
70 in which case the request is terminated with an error
179
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
71 <http-status code="503" text="Service Temporarily Unavailable"/>.
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
4c6d2c614d2c Cleaned up XML tag mess:
Ruslan Ermilov <ru@nginx.com>
parents: 270
diff changeset
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
4c6d2c614d2c Cleaned up XML tag mess:
Ruslan Ermilov <ru@nginx.com>
parents: 270
diff changeset
124 <literal>info</literal> |
4c6d2c614d2c Cleaned up XML tag mess:
Ruslan Ermilov <ru@nginx.com>
parents: 270
diff changeset
125 <literal>notice</literal> |
4c6d2c614d2c Cleaned up XML tag mess:
Ruslan Ermilov <ru@nginx.com>
parents: 270
diff changeset
126 <literal>warn</literal> |
4c6d2c614d2c Cleaned up XML tag mess:
Ruslan Ermilov <ru@nginx.com>
parents: 270
diff changeset
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
95c3c3bbf1ce Text review.
Egor Nikitin <yegor.nikitin@gmail.com>
parents: 870
diff changeset
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
95c3c3bbf1ce Text review.
Egor Nikitin <yegor.nikitin@gmail.com>
parents: 870
diff changeset
139 Logging level for delays is one point less than for refusals; for example,
271
4c6d2c614d2c Cleaned up XML tag mess:
Ruslan Ermilov <ru@nginx.com>
parents: 270
diff changeset
140 if “<literal>limit_req_log_level notice</literal>” is specified,
4c6d2c614d2c Cleaned up XML tag mess:
Ruslan Ermilov <ru@nginx.com>
parents: 270
diff changeset
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
95c3c3bbf1ce Text review.
Egor Nikitin <yegor.nikitin@gmail.com>
parents: 870
diff changeset
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
4c6d2c614d2c Cleaned up XML tag mess:
Ruslan Ermilov <ru@nginx.com>
parents: 270
diff changeset
165 <literal>zone</literal>=<value>name</value>:<value>size</value>
4c6d2c614d2c Cleaned up XML tag mess:
Ruslan Ermilov <ru@nginx.com>
parents: 270
diff changeset
166 <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
167 <default/>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
168 <context>http</context>
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 <para>
966
95c3c3bbf1ce Text review.
Egor Nikitin <yegor.nikitin@gmail.com>
parents: 870
diff changeset
171 Sets parameters for a shared memory zone
95c3c3bbf1ce Text review.
Egor Nikitin <yegor.nikitin@gmail.com>
parents: 870
diff changeset
172 that will keep states for various keys.
95c3c3bbf1ce Text review.
Egor Nikitin <yegor.nikitin@gmail.com>
parents: 870
diff changeset
173 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
174 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
175 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
176 <note>
f15a983cac66 Limit conn/req: key is no longer limited to only one variable.
Ruslan Ermilov <ru@nginx.com>
parents: 1144
diff changeset
177 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
178 </note>
966
95c3c3bbf1ce Text review.
Egor Nikitin <yegor.nikitin@gmail.com>
parents: 870
diff changeset
179 Usage example:
179
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
180 <example>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
181 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
182 </example>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
183 </para>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
184
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
185 <para>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
186 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
187 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
188 1 request per second.
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
189 </para>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
190
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
191 <para>
966
95c3c3bbf1ce Text review.
Egor Nikitin <yegor.nikitin@gmail.com>
parents: 870
diff changeset
192 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
193 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
194 <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
195 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
196 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
197 The stored state always occupies
6c96a644b0b3 Corrected description of $binary_remote_addr and saved state.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 1629
diff changeset
198 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
199 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
200 or about 8 thousand 128-byte states.
966
95c3c3bbf1ce Text review.
Egor Nikitin <yegor.nikitin@gmail.com>
parents: 870
diff changeset
201 If the zone storage is exhausted, the server will return the
179
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
202 <http-status code="503" text="Service Temporarily Unavailable"/>
966
95c3c3bbf1ce Text review.
Egor Nikitin <yegor.nikitin@gmail.com>
parents: 870
diff changeset
203 error to all further requests.
179
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
204 </para>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
205
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
206 <para>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
207 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
208 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
209 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
210 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
211 </para>
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
212
8cc01e2179a9 - Reflected recent changes made to ngx_http_limit_conn_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
213 </directive>
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 </section>
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 </module>