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 提供支持
在本页
  • 指令
  • auth_http
  • auth_http_header
  • auth_http_pass_client_cert
  • auth_http_timeout
  • 协议
  • 原文档
  1. 核心功能
  2. Mail

ngx_mail_auth_http_module

上一页ngx_mail_core_module下一页ngx_mail_proxy_module

最后更新于5年前

指令

auth_http

-

说明

语法

auth_http URL;

默认

——

上下文

mail、server

设置 HTTP 认证服务器的 URL。协议描述。

auth_http_header

-

说明

语法

auth_http_header header value;

默认

——

上下文

mail、server

将指定的头附加到发送到身份验证服务器的请求。该头可以用作共享密钥,以验证请求来自 nginx。例如:

auth_http_header X-Auth-Key "secret_string";

auth_http_pass_client_cert

-

说明

语法

auth_http_pass_client_cert on | off;

默认

auth_http_pass_client_cert off;

上下文

mail、server

提示

该指令在 1.7.11 版本中出现

auth_http_timeout

-

说明

语法

auth_http_timeout time

默认

auth_http_timeout 60s;

上下文

mail、server

设置与认证服务器通信的超时时间。

协议

HTTP 协议用于与身份验证服务器进行通信。响应正文中的数据将被忽略,信息仅在头中传递。

请求和响应的示例:

请求:

GET /auth HTTP/1.0
Host: localhost
Auth-Method: plain # plain/apop/cram-md5/external
Auth-User: user
Auth-Pass: password
Auth-Protocol: imap # imap/pop3/smtp
Auth-Login-Attempt: 1
Client-IP: 192.0.2.42
Client-Host: client.example.org

好的响应:

HTTP/1.0 200 OK
Auth-Status: OK
Auth-Server: 198.51.100.1
Auth-Port: 143

坏的响应:

HTTP/1.0 200 OK
Auth-Status: Invalid login or password
Auth-Wait: 3

如果没有 Auth-Wait 头,则将返回错误并关闭连接。当前实现为每次身份验证尝试分配内存。仅在会话结束时才释放内存。因此,必须限制单个会话中无效身份验证尝试的次数 — 服务器必须在 10-20 次尝试后响应不带 Auth-Wait 头(尝试次数在 Auth-Login-Attempt 头中传递)。

使用 APOP 或 CRAM-MD5 时,请求-响应如下所示:

GET /auth HTTP/1.0
Host: localhost
Auth-Method: apop
Auth-User: user
Auth-Salt: <238188073.1163692009@mail.example.com>
Auth-Pass: auth_response
Auth-Protocol: imap
Auth-Login-Attempt: 1
Client-IP: 192.0.2.42
Client-Host: client.example.org

好的响应:

HTTP/1.0 200 OK
Auth-Status: OK
Auth-Server: 198.51.100.1
Auth-Port: 143
Auth-Pass: plain-text-pass

如果响应中存在 Auth-User 头,它将覆盖用于与后端进行身份验证的用户名。

对于 SMTP,响应还考虑了 Auth-Error-Code 头 — 如果存在,则在发生错误时用作响应代码。否则,将 535 5.7.0 代码添加到 Auth-Status 头中。

例如,如果从身份验证服务器收到以下响应:

HTTP/1.0 200 OK
Auth-Status: Temporary server problem, try again later
Auth-Error-Code: 451 4.3.0
Auth-Wait: 3

则 SMTP 客户端将收到错误

451 4.3.0 Temporary server problem, try again later

如果代理 SMTP 不需要身份验证,则请求将如下所示:

GET /auth HTTP/1.0
Host: localhost
Auth-Method: none
Auth-User:
Auth-Pass:
Auth-Protocol: smtp
Auth-Login-Attempt: 1
Client-IP: 192.0.2.42
Client-Host: client.example.org
Auth-SMTP-Helo: client.example.org
Auth-SMTP-From: MAIL FROM: <>
Auth-SMTP-To: RCPT TO: <postmaster@mail.example.com>

在 1.11.7 版本之前,FAILED 结果不包含原因字符串。

GET /auth HTTP/1.0
Host: localhost
Auth-Method: plain
Auth-User: user
Auth-Pass: password
Auth-Protocol: imap
Auth-Login-Attempt: 1
Client-IP: 192.0.2.42
Auth-SSL: on
Auth-SSL-Verify: SUCCESS
Auth-SSL-Subject: /CN=example.com
Auth-SSL-Issuer: /CN=example.com
Auth-SSL-Serial: C07AD56B846B5BFF
Auth-SSL-Fingerprint: 29d6a80a123d13355ed16b4b04605e29cb55a5ad

原文档

将 Auth-SSL-Cert 头和 PEM 格式(已编码)的证书附加到发送到身份验证服务器的请求。

对于 SSL/TLS 客户端连接(1.7.11),添加了 Auth-SSL 头,并且 Auth-SSL-Verify 将包含客户端证书验证的结果(如果):SUCCESS、FAILED:reason 和 NONE(如果不存在证书)。

存在客户端证书时,其详细信息将在以下请求头中传递:Auth-SSL-Subject、Auth-SSL-Issuer、Auth-SSL-Serial 和 Auth-SSL-Fingerprint。如果启用了 ,则证书本身将在 Auth-SSL-Cert 头中传递。该请求将如下所示:

http://nginx.org/en/docs/mail/ngx_mail_auth_http_module.html
指令
auth_http
auth_http_header
auth_http_pass_client_cert
auth_http_timeout
协议
如下
auth_http_pass_client_cert
客户端
启用