Skip to content

Commit e6d5fdf

Browse files
committed
Add ngx_http_session_log_module and ngx_http_ssi_module
1 parent 19ae81a commit e6d5fdf

File tree

4 files changed

+398
-5
lines changed

4 files changed

+398
-5
lines changed

SUMMARY.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,9 @@
2828
- [转换重写规则](How-To/转换重写规则.md)
2929
- [WebSocket 代理](How-To/WebSocket代理.md)
3030
- 开发
31-
- [贡献变更](开发/贡献变更.md)
31+
- [贡献指南](开发/贡献指南.md)
3232
- 开发指南
3333
- 模块参考
34-
- 指令字母索引
35-
- 变量字母索引
3634
- [核心功能](模块参考/核心功能.md)
3735
- HTTP
3836
- [ngx_http_core_module](模块参考/http/ngx_http_core_module.md)
@@ -77,11 +75,11 @@
7775
- [ngx_http_rewrite_module](模块参考/http/ngx_http_rewrite_module.md)
7876
- [ngx_http_scgi_module](模块参考/http/ngx_http_scgi_module.md)
7977
- [ngx_http_secure_link_module](模块参考/http/ngx_http_secure_link_module.md)
80-
- ngx_http_session_log_module
78+
- [ngx_http_session_log_module](模块参考/http/ngx_http_session_log_module.md)
8179
- [ngx_http_slice_module](模块参考/http/ngx_http_slice_module.md)
8280
- [ngx_http_spdy_module 被 ngx_http_v2_module 替代](模块参考/http/ngx_http_spdy_module.md)
8381
- [ngx_http_split_clients_module](模块参考/http/ngx_http_split_clients_module.md)
84-
- ngx_http_ssi_module
82+
- [ngx_http_ssi_module](模块参考/http/ngx_http_ssi_module.md)
8583
- ngx_http_ssl_module
8684
- ngx_http_status_module
8785
- ngx_http_stub_status_module
File renamed without changes.
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# ngx_http_session_log_module
2+
3+
- [示例配置](#example_configuration)
4+
- [指令](#directives)
5+
- [session_log](#session_log)
6+
- [session_log_format](#session_log_format)
7+
- [session_log_zone](#session_log_zone)
8+
- [内嵌变量](#embedded_variables)
9+
10+
`ngx_http_session_log_module` 模块启用会话日志(多个 HTTP 请求的聚合),而不是单个 HTTP 请求。
11+
12+
> 该模块作为我们[商业订阅](http://nginx.com/products/?_ga=2.22237371.1497417506.1556973333-896013220.1554004850)的一部分提供。
13+
14+
<a id="example_configuration"></a>
15+
16+
## 示例配置
17+
18+
以下配置根据请求客户端的地址和 **User-Agent** 请求头字段设置会话日志并将请求映射到会话:
19+
20+
```nginx
21+
session_log_zone /path/to/log format=combined
22+
zone=one:1m timeout=30s
23+
md5=$binary_remote_addr$http_user_agent;
24+
25+
location /media/ {
26+
session_log one;
27+
}
28+
```
29+
30+
31+
<a id="directives"></a>
32+
33+
## 指令
34+
35+
### session_log
36+
37+
|\-|说明|
38+
|:------|:------|
39+
|**语法**|**session_log** `name` &#124; `off`;|
40+
|**默认**|session_log off;|
41+
|**上下文**|http、server、location|
42+
43+
允许使用指定的会话日志。特殊值 `off` 取消从先前配置级别继承的所有 `session_log` 指令。
44+
45+
### session_log_format
46+
47+
|\-|说明|
48+
|:------|:------|
49+
|**语法**|**session_log_format** `name string ...`;|
50+
|**默认**|session_log_format combined "...";|
51+
|**上下文**|http|
52+
53+
指定日志的输出格式。`$body_bytes_sent` 变量的值聚合在会话的所有请求中。可用于记录的所有其他变量的值对应于会话中的第一个请求。
54+
55+
### session_log_zone
56+
57+
|\-|说明|
58+
|:------|:------|
59+
|**语法**|**session_log_zone** `path zone=name:size [format=format] [timeout=time] [id=id] [md5=md5]`;|
60+
|**默认**|——|
61+
|**上下文**|http|
62+
63+
设置日志文件的路径,并配置用于存储当前活动会话的共享内存区域。
64+
65+
只要会话中的最后一个请求经过的时间不超过指定的 `timeout`(默认为 30 秒),会话就被视为活动状态。会话不再处于活动状态后将被写入日志。
66+
67+
`id` 参数标识请求映射到的会话。`id` 参数设置为 MD5 哈希的十六进制形式(例如,使用变量从 cookie 中获取)。如果未指定此参数或不是有效的 MD5 哈希,则 nginx 将根据 `md5` 参数的值计算 MD5 哈希,并使用此哈希创建新会话。`id``md5` 参数都可以包含变量。
68+
69+
`format` 参数设置 [session_log_format](#session_log_format) 指令配置的自定义会话日志格式。如果未指定 `format`,则使用预定义的 `combined`格式。
70+
71+
<a id="embedded_variables"></a>
72+
73+
## 内嵌变量
74+
75+
`ngx_http_session_log_module` 模块支持两个内嵌变量:
76+
77+
- `$session_log_id`
78+
79+
当前会话 ID
80+
81+
- `$session_log_binary_id`
82+
83+
二进制形式的当前会话 ID(16字节)。
84+
85+
## 原文档
86+
87+
- [http://nginx.org/en/docs/http/ngx_http_session_log_module.html](http://nginx.org/en/docs/http/ngx_http_session_log_module.html)

0 commit comments

Comments
 (0)