带有 Postfix 和 SSL 的虚拟域

nim*_*odm 26 ssl postfix

我有一个 Postfix 邮件服务器设置,用于托管多个虚拟域(比如xxx.comyyy.com)。

用户将他们的外发邮件服务器配置为mail.xxx.commail.yyy.com。所有邮件服务器都指向同一个物理 Postfix 服务器(相同的 IP,在这个 Linux 服务器上运行的 Postfix 的单个实例)。

Postfixsmtpd_tls_cert_file配置选项需要哪个 SSL 证书?

还是我必须用一个证书mail.xxx.com,并告诉用户yyy.com在使用mail.xxx.com他们的发送邮件服务器?这将打破单独虚拟服务器的错觉。

[注意:域是完全独立的。这些不是共享公共根的多个子域]。

Pet*_*ter 21

实际上...如果您希望每个域都使用有效的 SSL 证书,您有 2 个解决方案:使用多域证书,或者在唯一的 IP 上设置每个域。第一个解决方案很糟糕:这些证书通常非常昂贵(尽管您可以找到便宜的证书),它们会在同一个证书上列出您希望认证的所有域,而且最重要的是,它们只颁发一次,因此添加只需一个新域就意味着获得一个全新的证书。

更好的解决方案是将每个域放在自己的 IP 上,然后将每个证书与其各自的 IP 进行匹配。

以下是您在 postfix 中的操作方法。

您将首先将每个域的证书放在/etc/postfix/目录中(您也可以创建一个/etc/postfix/ssl/目录) 注意:我使用 Plesk,它使用 .pem 证书文件,但您也可以使用.key 和 .cer 文件(.pem 文件只是 .key 和 .cer 文件的串联,按此顺序)

然后,你需要修改/etc/postfix/中master.cf文件

最初,我的看起来像这样(可能是因为我在设置服务器后添加了最后 3 个 IP:

1.1.1.1- unix - n n - - smtp -o smtp_bind_address=1.1.1.1 -o smtp_bind_address6= -o smtp_address_preference=ipv4

2.2.2.2- unix - n n - - smtp -o smtp_bind_address=2.2.2.2 -o smtp_bind_address6= -o smtp_address_preference=ipv4

smtp inet n - n - - smtpd
smtps inet n - n - - smtpd -o smtpd_tls_wrappermode=yes
submission inet n - n - - smtpd -o smtpd_enforce_tls=yes -o smtpd_tls_security_level=encrypt -o smtpd_sasl_auth_enable=yes -o smtpd_client_restrictions=permit_sasl_authenticate d,reject -o smtpd_sender_restrictions=

3.3.3.3- unix - n n - - smtp -o smtp_bind_address=3.3.3.3 -o smtp_bind_address6= -o smtp_address_preference=ipv4

4.4.4.4- unix - n n - - smtp -o smtp_bind_address=4.4.4.4 -o smtp_bind_address6= -o smtp_address_preference=ipv4

5.5.5.5- unix - n n - - smtp -o smtp_bind_address=5.5.5.5 -o smtp_bind_address6= -o smtp_address_preference=ipv4
Run Code Online (Sandbox Code Playgroud)

现在,要将每个证书绑定到其对应的 IP,请执行以下操作:

1.1.1.1- unix - n n - - smtp -o smtp_bind_address=1.1.1.1 -o smtp_bind_address6= -o smtp_address_preference=ipv4

2.2.2.2- unix - n n - - smtp -o smtp_bind_address=2.2.2.2 -o smtp_bind_address6= -o smtp_address_preference=ipv4

3.3.3.3- unix - n n - - smtp -o smtp_bind_address=3.3.3.3 -o smtp_bind_address6= -o smtp_address_preference=ipv4

4.4.4.4- unix - n n - - smtp -o smtp_bind_address=4.4.4.4 -o smtp_bind_address6= -o smtp_address_preference=ipv4

5.5.5.5- unix - n n - - smtp -o smtp_bind_address=5.5.5.5 -o smtp_bind_address6= -o smtp_address_preference=ipv4

#smtp inet n - n - - smtpd
#smtps inet n - n - - smtpd -o smtpd_tls_wrappermode=yes
#submission inet n - n - - smtpd -o smtpd_enforce_tls=yes -o smtpd_tls_security_level=encrypt -o smtpd_sasl_auth_enable=yes -o smtpd_client_restrictions=permit_sasl_authenticated,reject -o smtpd_sender_restrictions=

1.1.1.1:smtp inet n - n - - smtpd -o smtpd_tls_cert_file=/etc/postfix/cert1.pem -o smtpd_tls_key_file=/etc/postfix/cert1.pem
1.1.1.1:smtps inet n - n - - smtpd -o smtpd_tls_wrappermode=yes -o smtpd_tls_cert_file=/etc/postfix/cert1.pem -o smtpd_tls_key_file=/etc/postfix/cert1.pem
1.1.1.1:submission inet n - n - - smtpd -o smtpd_enforce_tls=yes -o smtpd_tls_security_level=encrypt -o smtpd_sasl_auth_enable=yes -o smtpd_client_restrictions=permit_sasl_authenticated,reject -o smtpd_sender_restrictions= -o smtpd_tls_cert_file=/etc/postfix/cert1.pem -o smtpd_tls_key_file=/etc/postfix/cert1.pem

2.2.2.2:smtp inet n - n - - smtpd -o smtpd_tls_cert_file=/etc/postfix/cert2.pem -o smtpd_tls_key_file=/etc/postfix/cert2.pem
2.2.2.2:smtps inet n - n - - smtpd -o smtpd_tls_wrappermode=yes -o smtpd_tls_cert_file=/etc/postfix/cert2.pem -o smtpd_tls_key_file=/etc/postfix/cert2.pem
2.2.2.2:submission inet n - n - - smtpd -o smtpd_enforce_tls=yes -o smtpd_tls_security_level=encrypt -o smtpd_sasl_auth_enable=yes -o smtpd_client_restrictions=permit_sasl_authenticated,reject -o smtpd_sender_restrictions= -o smtpd_tls_cert_file=/etc/postfix/cert2.pem -o smtpd_tls_key_file=/etc/postfix/cert2.pem

3.3.3.3:smtp inet n - n - - smtpd -o smtpd_tls_cert_file=/etc/postfix/cert3.pem -o smtpd_tls_key_file=/etc/postfix/cert3.pem
3.3.3.3:smtps inet n - n - - smtpd -o smtpd_tls_wrappermode=yes -o smtpd_tls_cert_file=/etc/postfix/cert3.pem -o smtpd_tls_key_file=/etc/postfix/cert3.pem
3.3.3.3:submission inet n - n - - smtpd -o smtpd_enforce_tls=yes -o smtpd_tls_security_level=encrypt -o smtpd_sasl_auth_enable=yes -o smtpd_client_restrictions=permit_sasl_authenticated,reject -o smtpd_sender_restrictions= -o smtpd_tls_cert_file=/etc/postfix/cert3.pem -o smtpd_tls_key_file=/etc/postfix/cert3.pem

4.4.4.4:smtp inet n - n - - smtpd -o smtpd_tls_cert_file=/etc/postfix/cert4.pem -o smtpd_tls_key_file=/etc/postfix/cert4.pem
4.4.4.4:smtps inet n - n - - smtpd -o smtpd_tls_wrappermode=yes -o smtpd_tls_cert_file=/etc/postfix/cert4.pem -o smtpd_tls_key_file=/etc/postfix/cert4.pem
4.4.4.4:submission inet n - n - - smtpd -o smtpd_enforce_tls=yes -o smtpd_tls_security_level=encrypt -o smtpd_sasl_auth_enable=yes -o smtpd_client_restrictions=permit_sasl_authenticated,reject -o smtpd_sender_restrictions= -o smtpd_tls_cert_file=/etc/postfix/cert4.pem -o smtpd_tls_key_file=/etc/postfix/cert4.pem

5.5.5.5:smtp inet n - n - - smtpd -o smtpd_tls_cert_file=/etc/postfix/cert5.pem -o smtpd_tls_key_file=/etc/postfix/cert5.pem
5.5.5.5:smtps inet n - n - - smtpd -o smtpd_tls_wrappermode=yes -o smtpd_tls_cert_file=/etc/postfix/cert5.pem -o smtpd_tls_key_file=/etc/postfix/cert5.pem
5.5.5.5:submission inet n - n - - smtpd -o smtpd_enforce_tls=yes -o smtpd_tls_security_level=encrypt -o smtpd_sasl_auth_enable=yes -o smtpd_client_restrictions=permit_sasl_authenticated,reject -o smtpd_sender_restrictions= -o smtpd_tls_cert_file=/etc/postfix/cert5.pem -o smtpd_tls_key_file=/etc/postfix/cert5.pem
Run Code Online (Sandbox Code Playgroud)

就是这样!!(不要忘记注释掉上面看到的原始行)

PS:如果您使用 courier-imap,要对 POP/IMAP 执行相同的操作,您只需将这些 .pem 文件的副本放置在/usr/share/courier-imap/(或者在 Plesk 的情况下,您将它们放置在/usr /share/ ) 并按如下方式命名它们: imapd.pem.xx.xx.xx.xx pop3d.pem.xx.xx.xx.xx

其中 xx.xx.xx.xx 是各自的 IP 地址(2 个证书是同一文件的副本)

希望这可以帮助!

  • 这就是希望!我花了一段时间才把它拼凑起来,很少能找到*实际*有效的解决方案,而不是有人猜测这个或那个可能有效。 (2认同)

jos*_*chi 13

或者我是否必须为 mail.xxx.com 使用单个证书并告诉 yyy.com 的用户使用 mail.xxx.com 作为他们的外发服务器?

是的,最终您必须这样做或使用具有多个CommonNameSubjAltName属性的证书。

Postfix 无法知道客户端请求的主机名。没有 ieHost表示请求的域的 HTTP/1.1标头之类的东西,而 Postfix 尚不支持SNI

如果您的邮件服务器确实依赖于两个不同的域,则必须smtpd在两个单独的网络接口/IP 地址上运行两个实例。通常,您只需选择一个“中立”域并告诉您的用户使用它。