非常教程

Nginx参考手册

ngx_mail_auth_http_module

ngx_mail_auth_http_module

  • 指令
  • auth_http
  • auth_http_header
  • auth_http_pass_client_cert
  • auth_http_timeout
  • 协议

指令

句法:

auth_http URL;

默认:

语境:

邮件,服务器

设置HTTP验证服务器的URL。协议如下所述。

句法:

auth_http_header头部值;

默认:

语境:

邮件,服务器

将指定的标头附加到发送给认证服务器的请求。这个头可以用作共享密钥来验证请求来自nginx。例如:

auth_http_header X-Auth-Key "secret_string";

句法:

auth_http_pass_client_cert在|上 关闭;

默认:

auth_http_pass_client_cert off;

语境:

邮件,服务器

将带有PEM格式(urlencoded)的客户端证书的“Auth-SSL-Cert”标头追加到发送给认证服务器的请求中。

句法:

auth_http_timeout时间;

默认:

auth_http_timeout 60s;

语境:

邮件,服务器

设置与验证服务器进行通信的超时时间。

协议

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>

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

在版本1.11.7之前,“ FAILED”结果不包含reason字符串。

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

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
ngx_mail_auth_http_module
Nginx

Nginx是一款轻量级的 Web 服务器/反向代理服务器及电子邮件代理服务器,可在 BSD-like 协议下发行。其特点是占有内存少,并发能力强。

主页 https://nginx.org/
源码 http://hg.nginx.org/nginx
发布版本 1.13.6

Nginx目录

1.指南 | Guides
2.核心 | Core
3.ngx_google_perftools_module
4.ngx_http_access_module
5.ngx_http_addition_module
6.ngx_http_api_module
7.ngx_http_auth_basic_module
8.ngx_http_auth_jwt_module
9.ngx_http_auth_request_module
10.ngx_http_autoindex_module
11.ngx_http_browser_module
12.ngx_http_charset_module
13.ngx_http_core_module
14.ngx_http_dav_module
15.ngx_http_empty_gif_module
16.ngx_http_f4f_module
17.ngx_http_fastcgi_module
18.ngx_http_flv_module
19.ngx_http_geoip_module
20.ngx_http_geo_module
21.ngx_http_gunzip_module
22.ngx_http_gzip_module
23.ngx_http_gzip_static_module
24.ngx_http_headers_module
25.ngx_http_hls_module
26.ngx_http_image_filter_module
27.ngx_http_index_module
28.ngx_http_js_module
29.ngx_http_keyval_module
30.ngx_http_limit_conn_module
31.ngx_http_limit_req_module
32.ngx_http_log_module
33.ngx_http_map_module
34.ngx_http_memcached_module
35.ngx_http_mirror_module
36.ngx_http_mp4_module
37.ngx_http_perl_module
38.ngx_http_proxy_module
39.ngx_http_random_index_module
40.ngx_http_realip_module
41.ngx_http_referer_module
42.ngx_http_rewrite_module
43.ngx_http_scgi_module
44.ngx_http_secure_link_module
45.ngx_http_session_log_module
46.ngx_http_slice_module
47.ngx_http_spdy_module
48.ngx_http_split_clients_module
49.ngx_http_ssi_module
50.ngx_http_ssl_module
51.ngx_http_status_module
52.ngx_http_stub_status_module
53.ngx_http_sub_module
54.ngx_http_upstream_conf_module
55.ngx_http_upstream_hc_module
56.ngx_http_upstream_module
57.ngx_http_userid_module
58.ngx_http_uwsgi_module
59.ngx_http_v2_module
60.ngx_http_xslt_module
61.ngx_mail_auth_http_module
62.ngx_mail_core_module
63.ngx_mail_imap_module
64.ngx_mail_pop3_module
65.ngx_mail_proxy_module
66.ngx_mail_smtp_module
67.ngx_mail_ssl_module
68.ngx_stream_access_module
69.ngx_stream_core_module
70.ngx_stream_geoip_module
71.ngx_stream_geo_module
72.ngx_stream_js_module
73.ngx_stream_limit_conn_module
74.ngx_stream_log_module
75.ngx_stream_map_module
76.ngx_stream_proxy_module
77.ngx_stream_realip_module
78.ngx_stream_return_module
79.ngx_stream_split_clients_module
80.ngx_stream_ssl_module
81.ngx_stream_ssl_preread_module
82.ngx_stream_upstream_hc_module
83.ngx_stream_upstream_module