模块 ngx_http_userid_module
示例Directives userid userid_domain userid_expires userid_flags userid_mark userid_name userid_p3p userid_path userid_service 嵌入变量 |
该模块设置 cookie
适合客户识别。
可以使用嵌入式变量 $uid_got 和 $uid_set 记录接收和设置的 Cookie。
此模块与 Apache 的 mod_uid 模块兼容。ngx_http_userid_module
示例配置
userid on; userid_name uid; userid_domain example.com; userid_path /; userid_expires 365d; userid_p3p 'policyref="/w3c/p3p.xml", CP="CUR ADM OUR NOR STA NID"';
Directives
语法: |
userid
|
---|---|
默认值: |
userid off; |
上下文: |
http , ,server location |
启用或禁用设置 Cookie 并记录收到的 Cookie:
on
- 启用版本 2 Cookie 的设置 以及记录收到的 cookie;
v1
- 启用版本 1 Cookie 的设置 以及记录收到的 cookie;
log
- 禁用 cookie 的设置, 但允许记录收到的 cookie;
off
- 禁用 Cookie 的设置和接收的 Cookie 的日志记录。
语法: |
userid_domain |
---|---|
默认值: |
userid_domain none; |
上下文: |
http , ,server location |
定义为其设置 Cookie 的域。
该参数禁用
饼干。none
语法: |
userid_expires |
---|---|
默认值: |
userid_expires off; |
上下文: |
http , ,server location |
设置浏览器应保留 Cookie 的时间。
该参数将导致 Cookie 在
“”.
该参数将导致 Cookie 在
浏览器会话的结束。max
31 Dec 2037 23:55:55 GMT
off
语法: |
userid_flags
|
---|---|
默认值: |
userid_flags off; |
上下文: |
http , ,server location |
该Directives出现在版本 1.19.3 中。
如果参数不是 ,
定义 Cookie 的一个或多个附加标志: 、 、 、 、 。off
secure
httponly
samesite=strict
samesite=lax
samesite=none
语法: |
userid_mark
|
---|---|
默认值: |
userid_mark off; |
上下文: |
http , ,server location |
如果参数不是 ,则启用 Cookie 标记
机制,并设置用作标记的字符。
此机制用于添加或更改 userid_p3p 和/或 Cookie 过期时间,而
保留客户端标识符。
标记可以是英文字母表的任何字母(区分大小写),
digit 或 “” 字符。off
=
如果设置了标记,则会将其与第一个填充符号进行比较 在 Cookie 中传递的客户端标识符的 base64 表示形式中。 如果它们不匹配,则使用指定的标记 (即 cookie) 重新发送 cookie 过期时间和 “P3P” 标头。
语法: |
userid_name |
---|---|
默认值: |
userid_name uid; |
上下文: |
http , ,server location |
设置 Cookie 名称。
语法: |
userid_p3p |
---|---|
默认值: |
userid_p3p none; |
上下文: |
http , ,server location |
为 “P3P” 标头字段设置一个值,该值将为
与 Cookie 一起发送。
如果Directives设置为 special value ,
“P3P” 标头不会在响应中发送。none
语法: |
userid_path |
---|---|
默认值: |
userid_path /; |
上下文: |
http , ,server location |
定义为其设置 Cookie 的路径。
语法: |
userid_service |
---|---|
默认值: |
userid_service IP address of the server; |
上下文: |
http , ,server location |
如果标识符由多个服务器(服务)颁发,
每个服务都应该分配自己的服务,以确保客户端标识符是唯一的。
对于版本 1 Cookie,默认值为零。
对于版本 2 Cookie,默认值是由最后一个
服务器 IP 地址的四个八位字节。number
嵌入变量
模块
支持以下嵌入变量:ngx_http_userid_module
$uid_got
- Cookie 名称和收到的客户端标识符。
$uid_reset
- 如果变量设置为非 “” 的非空字符串,
客户端标识符将被重置。
特殊值 “” 还会导致
有关重置标识符的消息 error_log.
0
log
$uid_set
- Cookie 名称和发送的客户端标识符。