Module ngx_http_userid_module

ngx_http_userid_module模块设置适合于客户机标识的 cookie。可以使用嵌入式变量$uid_got$uid_set记录接收和设置的 cookie。该模块与 Apache 的mod_uid模块兼容。

Example Configuration

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

Syntax:userid on | v1 | log | off;
Default:userid off;
Context:http , server , location

启用或禁用设置 cookie 并记录接收到的 cookie:

  • on

    • 启用版本 2 cookie 的设置和接收到的 cookie 的日志记录;
  • v1

    • 启用版本 1 cookie 的设置和接收到的 cookie 的日志记录;
  • log

    • 禁用 cookie 的设置,但启用对收到的 cookie 的日志记录;
  • off

    • 禁用 cookie 的设置和接收到的 cookie 的日志记录。

Syntax:userid_domain name | none;
Default:userid_domain none;
Context:http , server , location

定义为其设置 cookie 的域。 none参数禁用 cookie 的域设置。

Syntax:userid_expires time | max | off;
Default:userid_expires off;
Context:http , server , location

设置浏览器保留 cookie 的时间。参数max将导致 Cookie 在“ 31 Dec 2037 23:55:55 GMT”上过期。参数off将导致 Cookie 在浏览器会话结束时过期。

Syntax:userid_mark letter | digit | = | off;
Default:userid_mark off;
Context:http , server , location

如果参数不是off,则启用 cookie 标记机制并设置用作标记的字符。此机制用于添加或更改userid_p3p和/或 cookie 到期时间,同时保留客户端标识符。标记可以是英文字母(区分大小写),数字或“ =”的任何字母。

如果设置了标记,则将其与 cookie 中传递的客户端标识符的 base64 表示形式中的第一个填充符号进行比较。如果它们不匹配,则使用指定的标记,到期时间和“ P3P”Headers 重新发送 Cookie。

Syntax:userid_name name;
Default:userid_name uid;
Context:http , server , location

设置 cookie 名称。

Syntax:userid_p3p string | none;
Default:userid_p3p none;
Context:http , server , location

为“ P3P”Headers 字段设置一个值,该值将与 Cookie 一起发送。如果指令设置为特殊值none,则不会在响应中发送“ P3P”Headers。

Syntax:userid_path path;
Default:userid_path /;
Context:http , server , location

定义为其设置 cookie 的路径。

Syntax:userid_service number;
Default:userid_service IP address of the server;
Context:http , server , location

如果标识符是由多个服务器(服务)发布的,则应为每个服务分配自己的number,以确保客户端标识符是唯一的。对于版本 1 Cookie,默认值为零。对于版本 2 Cookie,默认值为从服务器 IP 地址的最后四个八位字节组成的数字。

Embedded Variables

ngx_http_userid_module模块支持以下嵌入式变量:

$uid_got

  • Cookie 名称和收到的客户端标识符。

$uid_reset

  • 如果变量设置为非“ 0”的非空字符串,则将重置客户端标识符。特殊值“ log”还导致将有关重置标识符的消息输出到error_log

$uid_set

  • Cookie 名称和已发送的客户端标识符。