在Ubuntu上使用SNI的多个SSL

时间:2015-10-19 23:25:14

标签: apache ubuntu ssl

  • Apache / 2.4.7(Ubuntu)
  • Ubuntu 14.04

我试图在同一个ip上运行多个ssl。当我输入第一个域时,它会重定向到第二个域。

我可能在某个地方遗漏了一件小事,如果你可以帮助我那会很棒。

我关注了the DO tutorial而没有更改ports.conf文件(因为我不再使用NameVirtualHost的印象)。

我在启用网站的目录中有两个.conf文件,我尝试合并它们但得到相同的结果。

apachectl -S的输出是:

@Security("user.getSites().contains(site)")

这是我的ports.conf(应该是默认的Ubuntu):

*:443 is a NameVirtualHost
 default server domain2.com (/etc/apache2/sites-enabled/domain2.com.conf:19)
 port 443 namevhost domain2.com (/etc/apache2/sites-enabled/domain2.com.conf:19)
 port 443 namevhost www.domain1.com (/etc/apache2/sites-enabled/domain1.com.conf:19)
     alias domain1.com
     wild alias *.domain1.com

我已尝试从mod_ssl切换到mod_gnutls(使用更新的conf文件)并获得相同的结果。

启用网站的域1 .conf文件:

Listen 80

<IfModule ssl_module>
    Listen 443
</IfModule>

<IfModule mod_gnutls.c>
    Listen 443
</IfModule>

Domain 2 conf:

<VirtualHost *:80>
    ServerName domain1.com
    ServerAlias www.domain1.com *.domain1.com 
    DocumentRoot /git/domain1.com/public/
    ServerAdmin webmaster@domain1.com

    <Directory /git/domain1.com/public/>
        Options +Indexes +FollowSymLinks -MultiViews
        AllowOverride All
        Require all granted
    </Directory>

    ErrorLog /var/log/apache2/error_domain1.com.log
</VirtualHost>

<IfModule mod_ssl.c>
<VirtualHost *:443>

        ServerAdmin webmaster@domain1.com
        ServerName domain1.com
        DocumentRoot /git/domain1.com/public/

        #   SSL Engine Switch:
        #   Enable/Disable SSL for this virtual host.
        SSLEngine on

        #   A self-signed (snakeoil) certificate can be created by installing
        #   the ssl-cert package. See
        #   /usr/share/doc/apache2.2-common/README.Debian.gz for more info.
        #   If both key and certificate are stored in the same file, only the
        #   SSLCertificateFile directive is needed.
        SSLCertificateFile /git/domain1.com/apache/ssl/apache.crt
        SSLCertificateKeyFile /git/domain1.com/apache/ssl/apache.key

    <Directory /git/domain1.com/public/>
        Options +Indexes +FollowSymLinks -MultiViews
        AllowOverride All
        Require all granted
    </Directory>

</VirtualHost>

</IfModule>

1 个答案:

答案 0 :(得分:0)

*:443 is a NameVirtualHost
 default server domain2.com (/etc/apache2/sites-enabled/domain2.com.conf:19)
 port 443 namevhost domain2.com (/etc/apache2/sites-enabled/domain2.com.conf:19)
 port 443 namevhost www.domain1.com (/etc/apache2/sites-enabled/domain1.com.conf:19)
     alias domain1.com
     wild alias *.domain1.com

由于默认服务器是domain2.com,因此来自非SNI支持的浏览器的HTTPS请求可能会重定向到domain2.com,即使您打算访问www.domain1。 COM。

如果您确定客户端支持SNI,那么您可以调查的另一种可能性是,然后检查已安装的OpenSSL是否支持TLS,并且您的Apache是​​使用该OpenSSL版本构建的。必须满足服务器端和客户端先决条件,才能使基于名称的Apache虚拟主机正确处理请求。

更新1

启动服务器时,您可能会在错误日志中看到错误日志Init: Name-based SSL virtual hosts require an OpenSSL version with support for TLS extensions (RFC 6066 - Server Name Indication / SNI), but the currently used library version (%s) is lacking this feature

更新2

而且,虽然是apachectl -S

的结果
  port 443 namevhost www.domain1.com (/etc/apache2/sites-enabled/domain1.com.conf:19)
     alias domain1.com
     wild alias *.domain1.com

显示* .domain1.com或domain1.com将在您的domain1.conf中以www.domain1.com的形式处理

<VirtualHost *:443>

        ServerAdmin webmaster@domain1.com
        ServerName domain1.com

没有为这个虚拟主机定义任何别名,所以我想知道这个虚拟主机是否会处理你所假设的请求。