Nginx中文文档
DocsHome
  • 贡献导引
  • 介绍
    • 安装 nginx
    • 从源码构建 nginx
    • 初学者指南
    • 管理指南
    • 控制 nginx
    • 连接处理方式
    • 设置哈希
    • 调试日志
    • 记录日志到 syslog
    • 配置文件度量单位
    • 命令行参数
    • Windows 下的 nginx
    • QUIC 和 HTTP/3 支持
    • nginx 如何处理请求
    • 服务器名称
    • 使用 nginx 作为 HTTP 负载均衡器
    • 配置 HTTPS 服务器
    • nginx 如何处理 TCP/UDP 会话
    • 关于 nginScript
  • 其他
    • Linux 软件包
  • How-To
    • 在 Win32 平台上使用 Visual C 构建 nginx
    • 设置 Amazon EC2 的 Nginx Plus 环境
    • 使用 DTrace pid 提供程序调试 nginx
    • 转换重写规则
    • WebSocket 代理
  • 开发
    • 贡献指南
    • 开发指南
  • 模块参考
  • 核心功能
    • HTTP
      • ngx_http_core_module
      • ngx_http_access_module
      • ngx_http_addition_module
      • ngx_http_api_module
      • ngx_http_auth_basic_module
      • ngx_http_auth_jwt_module
      • ngx_http_auth_request_module
      • ngx_http_autoindex_module
      • ngx_http_browser_module
      • ngx_http_charset_module
      • ngx_http_dav_module
      • ngx_http_empty_gif_module
      • ngx_http_f4f_module
      • ngx_http_fastcgi_module
      • ngx_http_flv_module
      • ngx_http_geo_module
      • ngx_http_geoip_module
      • ngx_http_grpc_module
      • ngx_http_gunzip_module
      • ngx_http_gzip_module
      • ngx_http_gzip_static_module
      • ngx_http_headers_module
      • ngx_http_hls_module
      • ngx_http_image_filter_module
      • ngx_http_index_module
      • ngx_http_js_module
      • ngx_http_keyval_module
      • ngx_http_limit_conn_module
      • ngx_http_limit_req_module
      • ngx_http_log_module
      • ngx_http_map_module
      • ngx_http_memcached_module
      • ngx_http_mirror_module
      • ngx_http_mp4_module
      • ngx_http_perl_module
      • ngx_http_proxy_module
      • ngx_http_random_index_module
      • ngx_http_realip_module
      • ngx_http_referer_module
      • ngx_http_rewrite_module
      • ngx_http_scgi_module
      • ngx_http_secure_link_module
      • ngx_http_session_log_module
      • ngx_http_slice_module
      • ngx_http_spdy_module(过时)
      • ngx_http_split_clients_module
      • ngx_http_ssi_module
      • ngx_http_ssl_module
      • ngx_http_status_module(过时)
      • ngx_http_stub_status_module
      • ngx_http_sub_module
      • ngx_http_upstream_module
      • ngx_http_upstream_conf_module
      • ngx_http_upstream_hc_module
      • ngx_http_userid_module
      • ngx_http_uwsgi_module
      • ngx_http_v2_module
      • ngx_http_xslt_module
    • Mail
      • ngx_mail_core_module
      • ngx_mail_auth_http_module
      • ngx_mail_proxy_module
      • ngx_mail_ssl_module
      • ngx_mail_imap_module
      • ngx_mail_pop3_module
      • ngx_mail_smtp_module
    • Stream
      • ngx_stream_core_module
      • ngx_stream_access_module
      • ngx_stream_geo_module
      • ngx_stream_geoip_module
      • ngx_stream_js_module
      • ngx_stream_keyval_module
      • ngx_stream_limit_conn_module
      • ngx_stream_log_module
      • ngx_stream_map_module
      • ngx_stream_proxy_module
      • ngx_stream_realip_module
      • ngx_stream_return_module
      • ngx_stream_split_clients_module
      • ngx_stream_ssl_module
      • ngx_stream_ssl_preread_module
      • ngx_stream_upstream_module
      • ngx_stream_upstream_hc_module
      • ngx_stream_zone_sync_module
    • 其他
      • ngx_google_perftools_module
由 GitBook 提供支持
在本页
  • 示例配置
  • 指令
  • userid
  • userid_domain
  • userid_expires
  • userid_mark
  • userid_name
  • userid_p3p
  • userid_path
  • userid_service
  • 内嵌变量
  • 原文档
  1. 核心功能
  2. HTTP

ngx_http_userid_module

上一页ngx_http_upstream_hc_module下一页ngx_http_uwsgi_module

最后更新于5年前

ngx_http_userid_module 模块设置方便客户端识别的 cookie。可以使用内嵌变量 和 记录已接收和设置的 cookie。该模块与 Apache 的 模块兼容。

示例配置

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"';

指令

userid

-

说明

语法

userid on | v1 | log | off;

默认

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 name | none;

默认

userid_domain none;

上下文

http、server、location

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

userid_expires

-

说明

语法

userid_expires time | max | off;

默认

userid_expires off;

上下文

http、server、location

设置浏览器保留 cookie 的时间(time)。特殊值 max 将 cookie 设置在 31 Dec 2037 23:55:55 GMT 时到期。如果未指定参数,cookie 将在浏览器会话结束时到期。

userid_mark

-

说明

语法

userid_mark letter | digit | = | off;

默认

userid_mark off;

上下文

http、server、location

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

userid_name

-

说明

语法

userid_name name;

默认

userid_name uid;

上下文

http、server、location

设置 cookie 的名称。

userid_p3p

-

说明

语法

userid_p3p string | none;

默认

userid_p3p none;

上下文

http、server、location

设置将与 cookie 一起发送的 P3P 头字段的值。如果指令设置为特殊值 none,则不会在响应中发送 P3P 头。

userid_path

-

说明

语法

userid_path path;

默认

userid_path /;

上下文

http、server、location

为设置的 cookie 定义路径。

userid_service

-

说明

语法

userid_service number;

默认

userid_service 服务器的 IP 地址;

上下文

http、server、location

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

内嵌变量

ngx_http_userid_module 模块支持以下内嵌变量:

  • $uid_got

    cookie 名称和收到的客户端标识符

  • $uid_reset

  • $uid_set

    cookie 名称和已发送的客户端标识符

原文档

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

如果变量设置为非空字符串且非 "0",则重置客户端标识符。特殊值 log 会将关于重置标识符的消息输出到 。

http://nginx.org/en/docs/http/ngx_http_userid_module.html
mod_uid
示例配置
指令
userid
userid_domain
userid_expires
userid_mark
userid_name
userid_p3p
userid_path
userid_service
内嵌变量
$uid_got
$uid_set
userid_p3p
error_log