非常教程

Nginx参考手册

ngx_mail_core_module

ngx_mail_core_module

  • 示例配置
  • 指令
  • 邮件
  • 协议
  • 解决
  • resolver_timeout
  • 服务器
  • server_name
  • 时间到

该模块不是默认生成的,它应该使用--with-mail配置参数启用。

示例配置

worker_processes 1;

error_log /var/log/nginx/error.log info;

events {
    worker_connections  1024;
}

mail {
    server_name       mail.example.com;
    auth_http         localhost:9000/cgi-bin/nginxauth.cgi;

    imap_capabilities IMAP4rev1 UIDPLUS IDLE LITERAL+ QUOTA;

    pop3_auth         plain apop cram-md5;
    pop3_capabilities LAST TOP USER PIPELINING UIDL;

    smtp_auth         login plain cram-md5;
    smtp_capabilities "SIZE 10485760" ENHANCEDSTATUSCODES 8BITMIME DSN;
    xclient           off;

    server {
        listen   25;
        protocol smtp;
    }
    server {
        listen   110;
        protocol pop3;
        proxy_pass_error_message on;
    }
    server {
        listen   143;
        protocol imap;
    }
    server {
        listen   587;
        protocol smtp;
    }
}

指令

句法:

监听地址:port ssl rcvbuf = size bind [so_keepalive = on | off | keepidle:keepintvl:keepcnt];

默认:

语境:

服务器

设置address以及port对哪些服务器将接受请求的插座。可以只指定端口。地址也可以是主机名,例如:

listen 127.0.0.1:110;
listen *:110;
listen 110;     # same as *:110
listen localhost:110;

IPv6地址(0.7.58)在方括号中指定:

listen [::1]:110;
listen [::]:110;

UNIX域套接字(1.3.5)用“ unix:”前缀指定:

listen unix:/var/run/nginx.sock;

不同的服务器必须监听不同的addressport对。

ssl参数允许指定此端口上接受的所有连接都应该在SSL模式下工作。

listen指令可以具有特定于套接字相关系统调用的几个附加参数。

backlog= 在限制未决连接队列(1.9.2)队列的最大长度的调用中number设置backlog参数listen()。默认情况下,backlog在FreeBSD,DragonFly BSD和macOS上设置为-1,在其他平台上设置为511。rcvbuf= size设置SO_RCVBUF侦听套接字(1.11.13)的接收缓冲区大小(选项)。sndbuf= size设置SO_SNDBUF侦听套接字(1.11.13)的发送缓冲区大小(选项)。bind此参数指示bind()为给定地址:端口对进行单独调用。事实是,如果有几个listen指令具有相同的端口但地址不同,并且其中一个listen指令侦听给定端口的所有地址(*:port),nginx将bind()只会*:port。应该注意的getsockname()是,在这种情况下系统调用将确定接受连接的地址。如果使用ipv6onlyso_keepalive参数,那么对于给定的addressportbind()将始终进行单独的呼叫。ipv6only= on| off此参数确定(通过IPV6_V6ONLY套接字选项)侦听通配符地址的IPv6套接字是[::]仅接受IPv6连接还是接受IPv6和IPv4连接。该参数默认打开。它只能在启动时设置一次。so_keepalive= on| off| keepidlekeepintvlkeepcnt 此参数配置侦听套接字的“TCP keepalive”行为。如果省略此参数,则操作系统的设置将对套接字有效。如果它被设置为值“ on”,则SO_KEEPALIVE该插座的选项被打开。如果它设置为值“ off”,SO_KEEPALIVE则关闭套接字选项。在每个插槽的基础使用的TCP保活参数某些操作系统支持设置TCP_KEEPIDLETCP_KEEPINTVLTCP_KEEPCNT套接字选项。在这样的系统(目前,Linux的2.4 +,NetBSD的5+和FreeBSD 9.0-STABLE),它们可以使用配置的keepidlekeepintvlkeepcnt参数。一个或两个参数可以省略,在这种情况下,相应套接字选项的系统默认设置将生效。例如,

so_keepalive=30m::10

会将空闲超时(TCP_KEEPIDLE)设置为30分钟,将探测间隔(TCP_KEEPINTVL)保留在其系统默认值下,并将探测计数(TCP_KEEPCNT)设置为10个探测。

句法:

邮件{...}

默认:

语境:

主要

提供指定邮件服务器指令的配置文件上下文。

句法:

协议imap | pop3 | SMTP;

默认:

语境:

服务器

设置代理服务器的协议。支持的协议是IMAP,POP3和SMTP。

如果未指定该指令,则可以根据listen指令中指定的众所周知的端口自动检测协议:

  • imap: 143, 993
  • pop3: 110, 995
  • smtp: 25, 587, 465

不必要的协议可使用的配置参数被禁用--without-mail_imap_module--without-mail_pop3_module--without-mail_smtp_module

句法:

解析器地址...有效=时间;解析器关闭;

默认:

解析器关闭;

语境:

邮件,服务器

将用于查找客户端主机名的名称服务器配置为将其传递给身份验证服务器,并在代理SMTP时将该名称服务器配置到XCLIENT命令中。例如:

resolver 127.0.0.1 [::1]:5353;

地址可以指定为域名或IP地址,以及可选端口(1.3.1,1.2.2)。如果未指定端口,则使用端口53。名称服务器以循环方式查询。

在版本1.1.7之前,只能配置一个名称服务器。从版本1.3.1和1.2.2开始,支持使用IPv6地址指定名称服务器。

默认情况下,nginx使用响应的TTL值缓存答案。可选valid参数允许覆盖它:

resolver 127.0.0.1 [::1]:5353 valid=30s;

在版本1.1.9之前,调整缓存时间是不可能的,并且nginx始终缓存5分钟内的答案。

特殊值off禁用解析。

句法:

resolver_timeout时间;

默认:

resolver_timeout 30s;

语境:

邮件,服务器

为DNS操作设置超时,例如:

resolver_timeout 5s;

句法:

服务器{...}

默认:

语境:

邮件

设置服务器的配置。

句法:

server_name名称;

默认:

server_name主机名;

语境:

邮件,服务器

设置使用的服务器名称:

  • 在最初的POP3 / SMTP服务器问候中;
  • 在SASL CRAM-MD5认证期间的盐中;
  • EHLO连接到SMTP后端的命令中,如果XCLIENT命令的传递被启用。

如果未指定指令,则使用机器的主机名。

句法:

超时时间;

默认:

超时60秒;

语境:

邮件,服务器

设置代理到后端启动之前使用的超时。

ngx_mail_core_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