带有Postfix和SSL的虚拟域

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

用户将其发送邮件服务器configuration为mail.xxx.commail.yyy.com 。 所有的邮件服务器都是指同一个物理Postfix服务器(同一个IP,在这个Linux服务器上运行的Postfix的单个实例)。

我需要Postfix的哪个SSL证书smtpd_tls_cert_fileconfiguration选项?

或者我必须使用mail.xxx.com的单个证书,并告诉yyy.com用户使用mail.xxx.com作为他们的传出服务器? 这将打破单独虚拟服务器的错觉。

[注意:域是完全分开的。 这些不是共享一个共同的根的多个子域]。

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

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

Postfix无法知道客户端请求了哪个主机名。 没有这样的东西,即HTTP / 1.1 Host头表示请求的域名,而且Postfix目前还不支持SNI 。

如果你真的依赖于你的邮件服务器有两个不同的域,你将不得不在两个不同的networking接口/ IP地址上运行两个smtpd实例。 通常你只要select一个“中立”的域名,告诉你的用户使用它。

其实…如果你想要每个域使用一个有效的SSL证书,你有2个解决scheme:使用多域名证书,或设置每个域上一个唯一的IP。 第一个解决scheme是非常糟糕的:那些证书通常是相当昂贵的(虽然你可以find便宜的证书),他们会列出你想在同一个证书上certificate的所有域,最重要的是,它们只发布一次,只有一个新的域名意味着获得一个全新的证书。

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

这是你如何在后缀中做到这一点。

您将首先将每个域的证书放置在/ etc / postfix /目录中(您也可以创build/ etc / postfix / ssl /目录)注意:我使用Plesk,它使用.pem证书文件,但也可以使用.key和.cer文件(.pem文件只是.key和.cer文件的一个连续,依次)

那么你需要修改/ etc / postfix /

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

 1.1.1.1- unix - nn - - smtp -o smtp_bind_address=1.1.1.1 -o smtp_bind_address6= -o smtp_address_preference=ipv4 2.2.2.2- unix - nn - - 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 - nn - - smtp -o smtp_bind_address=3.3.3.3 -o smtp_bind_address6= -o smtp_address_preference=ipv4 4.4.4.4- unix - nn - - smtp -o smtp_bind_address=4.4.4.4 -o smtp_bind_address6= -o smtp_address_preference=ipv4 5.5.5.5- unix - nn - - smtp -o smtp_bind_address=5.5.5.5 -o smtp_bind_address6= -o smtp_address_preference=ipv4 

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

 1.1.1.1- unix - nn - - smtp -o smtp_bind_address=1.1.1.1 -o smtp_bind_address6= -o smtp_address_preference=ipv4 2.2.2.2- unix - nn - - smtp -o smtp_bind_address=2.2.2.2 -o smtp_bind_address6= -o smtp_address_preference=ipv4 3.3.3.3- unix - nn - - smtp -o smtp_bind_address=3.3.3.3 -o smtp_bind_address6= -o smtp_address_preference=ipv4 4.4.4.4- unix - nn - - smtp -o smtp_bind_address=4.4.4.4 -o smtp_bind_address6= -o smtp_address_preference=ipv4 5.5.5.5- unix - nn - - 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 

而已!! (不要忘记注释掉上面的原始行)

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个证书是同一文件的副本)

希望这可以帮助!