Skip to content

Commit e7c481d

Browse files
committed
Update stream section
1 parent 1f92f66 commit e7c481d

File tree

3 files changed

+589
-2
lines changed

3 files changed

+589
-2
lines changed

SUMMARY.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,12 @@
107107
- [ngx_stream_keyval_module](模块参考/stream/ngx_stream_keyval_module.md)
108108
- [ngx_stream_limit_conn_module](模块参考/stream/ngx_stream_limit_conn_module.md)
109109
- [ngx_stream_log_module](模块参考/stream/ngx_stream_log_module.md)
110-
- ngx_stream_map_module
110+
- [ngx_stream_map_module](模块参考/stream/ngx_stream_map_module.md)
111111
- [ngx_stream_proxy_module](模块参考/stream/ngx_stream_proxy_module.md)
112112
- [ngx_stream_realip_module](模块参考/stream/ngx_stream_realip_module.md)
113113
- [ngx_stream_return_module](模块参考/stream/ngx_stream_return_module.md)
114114
- [ngx_stream_split_clients_module](模块参考/stream/ngx_stream_split_clients_module.md)
115-
- ngx_stream_ssl_module
115+
- [ngx_stream_ssl_module](模块参考/stream/ngx_stream_ssl_module.md)
116116
- [ngx_stream_ssl_preread_module](模块参考/stream/ngx_stream_ssl_preread_module.md)
117117
- [ngx_stream_upstream_module](模块参考/stream/ngx_stream_upstream_module.md)
118118
- ngx_stream_upstream_hc_module
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
# ngx_stream_log_module
2+
3+
- [示例配置](#ngx_stream_map_module)
4+
- [指令](#directives)
5+
- [map](#map)
6+
- [map_hash_bucket_size](#map_hash_bucket_size)
7+
- [map_hash_max_size](#map_hash_max_size)
8+
9+
`ngx_stream_map_module` 模块(1.11.2)用于创建变量,其值取决于其他变量的值。
10+
11+
<a id="example_configuration"></a>
12+
13+
## 示例配置
14+
15+
```nginx
16+
map $remote_addr $limit {
17+
127.0.0.1 "";
18+
default $binary_remote_addr;
19+
}
20+
21+
limit_conn_zone $limit zone=addr:10m;
22+
limit_conn addr 1;
23+
```
24+
25+
<a id="directives"></a>
26+
27+
## 指令
28+
29+
### map
30+
31+
|\-|说明|
32+
|------:|------|
33+
|**语法**|**map** `string $variable { ... }`;|
34+
|**默认**|——|
35+
|**上下文**|stream|
36+
37+
创建一个新变量,其值取决于第一个参数中指定的一个或多个源变量的值。
38+
39+
> 由于仅在使用变量时才对它们进行求值,因此即使声明大量 `map` 变量,也不会为连接处理造成影响。
40+
41+
`map` 块内的参数指定一个源值和结果值之间的映射关系。
42+
43+
源值可为字符串或正则表达式。
44+
45+
字符串匹配时忽略大小写。
46+
47+
正则表达式应以 `~` 符号开头(区分大小写),或者以 `~*` 符号开头(区分大小写)。正则表达式可以包含命名捕获和位置捕获,这些捕获以后可以在其他指令中与结果变量一起使用。
48+
49+
如果源值与以下描述的特殊参数名称之一匹配,则应在其前面加上 `\` 转义符号。
50+
51+
结果值可以包含文本,变量及其组合。
52+
53+
还支持以下特殊参数:
54+
55+
- `default 默认值`
56+
57+
如果源值不匹配任何指定的变量值,则设置结果值。如果未指定 `default`,则默认结果值为空字符串
58+
59+
- `主机名`
60+
61+
指示源值可以是带有前缀或后缀掩码的主机名:
62+
63+
```
64+
*.example.com 1;
65+
example.* 1;
66+
```
67+
68+
以下两条记录
69+
70+
```
71+
example.com 1;
72+
*.example.com 1;
73+
```
74+
75+
可以组合在一起:
76+
77+
```
78+
.example.com 1;
79+
```
80+
81+
该参数应在值列表之前指定。
82+
83+
- `include 文件`
84+
85+
包含有值的文件。可包含多个
86+
87+
- `volatile`
88+
89+
表示该变量不可缓存(1.11.7)
90+
91+
如果源值匹配多个指定变体之一,例如 无论是掩码(mask)匹配还是正则表达式匹配,都将按照以下优先级顺序选择第一个匹配的变量值:
92+
93+
1. 不带掩码的字符串值
94+
2. 带有前缀掩码的最长字符串值,例如 `*.example.com`
95+
3. 带后缀掩码的最长字符串值,例如 `mail.*`
96+
4. 第一个匹配的正则表达式(在配置文件中出现的顺序)
97+
5. 默认值
98+
99+
### map_hash_bucket_size
100+
101+
|\-|说明|
102+
|------:|------|
103+
|**语法**|**map_hash_bucket_size** `size`;|
104+
|**默认**|map_hash_bucket_size 32&#124;64&#124;128;|
105+
|**上下文**|stream|
106+
107+
设置 [map](#map) 变量哈希表的存储桶大小。默认值取决于处理器的缓存行大小。有关设置哈希表的详细信息已在单独的[文档](../../介绍/设置哈希.md)中提供。
108+
109+
### map_hash_max_size
110+
111+
|\-|说明|
112+
|------:|------|
113+
|**语法**|**map_hash_max_size** `size`;|
114+
|**默认**|map_hash_max_size 2048;|
115+
|**上下文**|stream|
116+
117+
设置 [map](#map) 变量哈希表的最大大小(`size`)。有关设置哈希表的详细信息已在单独的[文档](../../介绍/设置哈希.md)中提供。
118+
119+
## 原文档
120+
[http://nginx.org/en/docs/stream/ngx_stream_map_module.html](http://nginx.org/en/docs/stream/ngx_stream_map_module.html)

0 commit comments

Comments
 (0)