【问题标题】:MAMP 2 Multiple VirtualHosts with SSLMAMP 2 使用 SSL 的多个虚拟主机
【发布时间】:2012-06-28 08:57:32
【问题描述】:

我目前在配置 MAMP 2 以将 SSL 与多个虚拟主机一起使用时遇到了麻烦(与一个虚拟主机一起工作正常)。就我而言,它只会为 https-ssl.conf 文件中列出的第一个虚拟主机提供 SSL 连接。

在我的 httpd-vhosts.conf 文件中,我有几个虚拟主机设置,例如:

<VirtualHost *:80> 
    DocumentRoot "/Users/me/sites/something/" 
    ServerName something.local 
</VirtualHost>
<VirtualHost *:80> 
    DocumentRoot "/Users/me/sites/else/" 
    ServerName else.local 
</VirtualHost>

在我的 https-ssl.conf 文件中,我有几个虚拟主机设置,例如:

<VirtualHost *:443>
    DocumentRoot "/Users/me/sites/something"
    ServerName something.local:443
    ServerAdmin you@example.com
    ErrorLog "/Applications/MAMP/Library/logs/error_log"
    TransferLog "/Applications/MAMP/Library/logs/access_log"

    SSLEngine on

    #   SSL Cipher Suite:
    SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL

    #   Server Certificate:
    SSLCertificateFile "/Applications/MAMP/conf/apache/server.crt"
    #SSLCertificateFile "/Applications/MAMP/conf/apache/server-dsa.crt"

    #   Server Private Key:
    SSLCertificateKeyFile "/Applications/MAMP/conf/apache/server.key"
    #SSLCertificateKeyFile "/Applications/MAMP/conf/apache/server-dsa.key"

    <FilesMatch "\.(cgi|shtml|phtml|php)$">
        SSLOptions +StdEnvVars
    </FilesMatch>
    <Directory "/Applications/MAMP/Library/cgi-bin">
        SSLOptions +StdEnvVars
    </Directory>

    #   SSL Protocol Adjustments:
    BrowserMatch ".*MSIE.*" \
             nokeepalive ssl-unclean-shutdown \
             downgrade-1.0 force-response-1.0

    #   Per-Server Logging:
    CustomLog "/Applications/MAMP/Library/logs/ssl_request_log" \
                  "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
</VirtualHost>  
<VirtualHost *:443>
    DocumentRoot "/Users/me/sites/else"
    ServerName else.local:443
    ServerAdmin you@example.com
    ErrorLog "/Applications/MAMP/Library/logs/error_log"
    TransferLog "/Applications/MAMP/Library/logs/access_log"


    ........add'l config deleted......
</VirtualHost>  

https-ssl.conf 中列出的第一个虚拟主机提供 SSL 支持总是有效,但后面没有列出任何虚拟主机(https://something.local 可以工作,但https://else.local 不行)

任何帮助将不胜感激!

【问题讨论】:

    标签: ssl mamp vhosts


    【解决方案1】:

    原始问题中的.conf 文件关闭,但不完全存在...

    为了让 Apache 通过 SSL 识别不同的虚拟主机,您需要使用 NameVirtualHost 并关闭“Strict SNI”。本质上,您需要在 httpd-ssl.conf 文件的顶部添加以下内容:

    # Ensure that Apache listens on port 443
    Listen 443
    
    # Listen for virtual host requests on all IP addresses
    NameVirtualHost *:443
    
    # Go ahead and accept connections for these vhosts
    # from non-SNI clients
    SSLStrictSNIVHostCheck off
    

    然后确保您的每个虚拟主机节点都使用以下标记声明:

    <VirtualHost *:443>
    

    注意:您使用的浏览器也需要支持 SNI。

    所有这些都取自 Apache 文档中的这个页面: https://wiki.apache.org/httpd/NameBasedSSLVHostsWithSNI

    【讨论】:

    • 谢谢!这对我有用。有趣的是SSLStrictSNIVHostCheck 没有在默认的httpd-ssl.conf 文件中提供(或记录)。
    【解决方案2】:

    如果包含在httpd-vhost.confhttpd.conf 上试试这个

    NameVirtualHost *:80
    NameVirtualHost *:443
    

    谢谢

    【讨论】:

      【解决方案3】:

      每个 IP 只能有一个 HTTPS 主机 - 这是 HTTPS 的限制。尝试 &lt;VirtualHost ip.ad.dr.es:443&gt; 为不同的 IP 获取一个 HTTPS 主机。

      【讨论】:

      • 啊,明白了。在本地环境中开发时是否有任何追索权?我四处寻找如何在 OSX (10.6) 上为 localhost 设置多个 IP,但找不到任何文档。
      • 我不是 OSX 人,但我认为是系统设置 -> 网络 -> 添加接口 -> 以太网 -> 然后是静态 IP 地址
      • 谢谢 - 我会调查的!
      • @EugenRieck TLS SNI、SAN 证书和通配符证书至少值得一提,不是吗?
      • @ShaneMadden 使用 MAMP 和 URL something.local 让我相信,这是用于测试设置,其中添加第二个 IP 将是迄今为止最快的解决方案。随意发布更多通过答案,我一定会赞成!
      猜你喜欢
      • 2014-08-06
      • 2023-03-13
      • 2019-06-11
      • 1970-01-01
      • 1970-01-01
      • 2019-03-01
      • 2012-09-03
      • 2017-11-19
      • 2010-09-05
      相关资源
      最近更新 更多