comparison xml/cn/docs/http/ngx_http_limit_conn_module.xml @ 720:9934338f83af

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