comparison xml/en/docs/stream/ngx_stream_limit_conn_module.xml @ 1517:53ae63cb4cfa

Added the limit_conn module for stream.
author Yaroslav Zhuravlev <yar@nginx.com>
date Thu, 18 Jun 2015 21:04:07 +0300
parents xml/en/docs/http/ngx_http_limit_conn_module.xml@7d028fc94593
children 6c96a644b0b3
comparison
equal deleted inserted replaced
1516:7ece86947201 1517:53ae63cb4cfa
1 <?xml version="1.0"?>
2
3 <!--
4 Copyright (C) Igor Sysoev
5 Copyright (C) Nginx, Inc.
6 -->
7
8 <!DOCTYPE module SYSTEM "../../../../dtd/module.dtd">
9
10 <module name="Module ngx_stream_limit_conn_module"
11 link="/en/docs/stream/ngx_stream_limit_conn_module.html"
12 lang="en"
13 rev="1">
14
15 <section id="summary">
16
17 <para>
18 The <literal>ngx_stream_limit_conn_module</literal> module (1.9.3) is used to
19 limit the number of connections per the defined key, in
20 particular, the number of connections from a single IP address.
21 </para>
22
23 </section>
24
25
26 <section id="example" name="Example Configuration">
27
28 <para>
29 <example>
30 stream {
31 limit_conn_zone $binary_remote_addr zone=addr:10m;
32
33 ...
34
35 server {
36
37 ...
38
39 limit_conn addr 1;
40 limit_conn_log_level error;
41 }
42 }
43 </example>
44 </para>
45
46 </section>
47
48
49 <section id="directives" name="Directives">
50
51 <directive name="limit_conn">
52 <syntax><value>zone</value> <value>number</value></syntax>
53 <default/>
54 <context>stream</context>
55 <context>server</context>
56
57 <para>
58 Sets the shared memory zone
59 and the maximum allowed number of connections for a given key value.
60 When this limit is exceeded, the server will close the connection.
61 For example, the directives
62 <example>
63 limit_conn_zone $binary_remote_addr zone=addr:10m;
64
65 server {
66 ...
67 limit_conn addr 1;
68 }
69 </example>
70 allow only one connection per an IP address at a time.
71 </para>
72
73 <para>
74 When several <literal>limit_conn</literal> directives are specified,
75 any configured limit will apply.
76 </para>
77
78 <para>
79 The directives are inherited from the previous level if and
80 only if there are no
81 <literal>limit_conn</literal>
82 directives on the current level.
83 </para>
84
85 </directive>
86
87
88 <directive name="limit_conn_log_level">
89 <syntax>
90 <literal>info</literal> |
91 <literal>notice</literal> |
92 <literal>warn</literal> |
93 <literal>error</literal></syntax>
94 <default>error</default>
95 <context>stream</context>
96 <context>server</context>
97
98 <para>
99 Sets the desired logging level for cases when the server
100 limits the number of connections.
101 </para>
102
103 </directive>
104
105
106 <directive name="limit_conn_zone">
107 <syntax>
108 <value>key</value>
109 <literal>zone</literal>=<value>name</value>:<value>size</value></syntax>
110 <default/>
111 <context>stream</context>
112
113 <para>
114 Sets parameters for a shared memory zone
115 that will keep states for various keys.
116 In particular, the state includes the current number of connections.
117 Currently, the supported value for the <value>key</value> is
118 the client address in the binary form specified as
119 <literal>$binary_remote_addr</literal>.
120 Connections with an empty key value are not accounted.
121 Usage example:
122 <example>
123 limit_conn_zone $binary_remote_addr zone=addr:10m;
124 </example>
125 Here, the key is a client IP address set by the
126 <literal>$binary_remote_addr</literal> key.
127 The size of <literal>$binary_remote_addr</literal>
128 is 4 bytes.
129 The stored state always occupies 32 bytes
130 on 32-bit platforms and 64 bytes on 64-bit platforms.
131 One megabyte zone can keep about 32 thousand 32-byte states
132 or about 16 thousand 64-byte states.
133 If the zone storage is exhausted, the server will close the connection.
134 </para>
135
136 </directive>
137
138
139 </section>
140
141 </module>