annotate xml/cn/docs/http/ngx_http_limit_conn_module.xml @ 2980:c80a7cb452e8

Linux packages: actualized supported Alpine Linux versions.
author Konstantin Pavlov <thresh@nginx.com>
date Fri, 16 Jun 2023 18:53:11 -0700
parents 9934338f83af
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
720
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
1 <?xml version="1.0"?>
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
2
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
3 <!--
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
4 Copyright (C) Igor Sysoev
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
5 Copyright (C) Nginx, Inc.
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
6 -->
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
7
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
8 <!DOCTYPE module SYSTEM "../../../../dtd/module.dtd">
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
9
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
10 <module name="ngx_http_limit_conn_module 模块"
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
11 link="/cn/docs/http/ngx_http_limit_conn_module.html"
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
12 lang="cn"
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
13 translator="G_will"
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
14 rev="1">
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
15
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
16 <section id="summary">
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
17
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
18 <para>
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
19 <literal>ngx_http_limit_conn_module</literal> 模块可以按照定义的键限定每个键值的连接数。特别的,可以设定单一 IP 来源的连接数。
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
20 </para>
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
21
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
22 <para>
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
23 并不是所有的连接都会被模块计数;只有那些正在被处理的请求(这些请求的头信息已被完全读入)所在的连接才会被计数。
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
24 </para>
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
25
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
26 </section>
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
27
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
28
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
29 <section id="example" name="配置范例">
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
30
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
31 <para>
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
32 <example>
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
33 http {
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
34 limit_conn_zone $binary_remote_addr zone=addr:10m;
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
35
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
36 ...
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
37
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
38 server {
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
39
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
40 ...
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
41
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
42 location /download/ {
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
43 limit_conn addr 1;
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
44 }
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
45 </example>
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
46 </para>
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
47
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
48 </section>
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
49
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
50
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
51 <section id="directives" name="指令">
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
52
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
53 <directive name="limit_conn">
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
54 <syntax><value>zone</value> <value>number</value></syntax>
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
55 <default/>
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
56 <context>http</context>
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
57 <context>server</context>
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
58 <context>location</context>
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
59
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
60 <para>
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
61 指定一块已经设定的共享内存空间,以及每个给定键值的最大连接数。当连接数超过最大连接数时,服务器将会返回
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
62 <http-status code="503" text="Service Temporarily Unavailable"/>
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
63 错误。比如,如下配置
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
64 <example>
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
65 limit_conn_zone $binary_remote_addr zone=addr:10m;
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
66
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
67 server {
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
68 location /download/ {
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
69 limit_conn addr 1;
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
70 }
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
71 </example>
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
72 表示,同一 IP 同一时间只允许有一个连接。
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
73 </para>
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
74
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
75 <para>
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
76 当多个 <literal>limit_conn</literal> 指令被配置时,所有的连接数限制都会生效。比如,下面配置不仅会限制单一IP来源的连接数,同时也会限制单一虚拟服务器的总连接数:
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
77 <example>
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
78 limit_conn_zone $binary_remote_addr zone=perip:10m;
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
79 limit_conn_zone $server_name zone=perserver:10m;
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
80
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
81 server {
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
82 ...
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
83 limit_conn perip 10;
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
84 limit_conn perserver 100;
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
85 }
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
86 </example>
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
87
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
88 </para>
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
89
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
90 <para>
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
91 如果当前配置层级没有<literal>limit_conn</literal>指令,将会从更高层级继承连接限制配置。
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
92 </para>
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
93
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
94 </directive>
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
95
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
96
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
97 <directive name="limit_conn_log_level">
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
98 <syntax>
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
99 <literal>info</literal> |
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
100 <literal>notice</literal> |
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
101 <literal>warn</literal> |
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
102 <literal>error</literal></syntax>
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
103 <default>error</default>
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
104 <context>http</context>
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
105 <context>server</context>
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
106 <context>location</context>
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
107 <appeared-in>0.8.18</appeared-in>
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
108
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
109 <para>
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
110 指定当连接数超过设定的最大连接数,服务器限制连接时的日志等级。
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
111 </para>
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
112
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
113 </directive>
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
114
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
115
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
116 <directive name="limit_conn_zone">
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
117 <syntax>
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
118 <value>$variable</value>
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
119 <literal>zone</literal>=<value>name</value>:<value>size</value></syntax>
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
120 <default/>
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
121 <context>http</context>
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
122
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
123 <para>
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
124 设定保存各个键的状态的共享内存空间的参数。键的状态中保存了当前连接数。键的值可以是特定变量的任何非空值(空值将不会被考虑)。
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
125 使用范例:
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
126 <example>
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
127 limit_conn_zone $binary_remote_addr zone=addr:10m;
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
128 </example>
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
129 这里,设置客户端的IP地址作为键。注意,这里使用的是<var>$binary_remote_addr</var>变量,而不是<var>$remote_addr</var>变量。<var>$remote_addr</var>变量的长度为7字节到15字节不等,而存储状态在32位平台中占用32字节或64字节,在64位平台中占用64字节。而<var>$binary_remote_addr</var>变量的长度是固定的4字节,存储状态在32位平台中占用32字节或64字节,在64位平台中占用64字节。一兆字节的共享内存空间可以保存3.2万个32位的状态,1.6万个64位的状态。如果共享内存空间被耗尽,服务器将会对后续所有的请求返回
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
130 <http-status code="503" text="Service Temporarily Unavailable"/>
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
131 错误。
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
132 </para>
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
133
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
134 </directive>
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
135
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
136
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
137 <directive name="limit_zone">
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
138 <syntax>
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
139 <value>name</value>
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
140 <value>$variable</value>
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
141 <value>size</value></syntax>
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
142 <default/>
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
143 <context>http</context>
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
144
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
145 <para>
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
146 这条指令在 1.1.8 版本中已经被废弃,应该使用等效的<link id="limit_conn_zone"/>指令。该指令的语法也有变化:
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
147 <note>
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
148 <literal>limit_conn_zone</literal>
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
149 <value>$variable</value>
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
150 <literal>zone</literal>=<value>name</value>:<value>size</value>;
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
151 </note>
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
152 </para>
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
153
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
154 </directive>
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
155
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
156 </section>
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
157
9934338f83af Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
158 </module>