Apache-2.2

本地子域和子子域上的 SSL

  • October 26, 2012

我同時擁有local.domain.comlmarket.local.domain.com從 etc/hosts 指向我的本地主機。

問題是我在 Windows 7 上使用 XAMPP,並且在我的 apache 配置中有 2 個 SSL 虛擬主機,但無論我訪問哪一個,我都會被帶到local.domain.com. 在非 HTTPS 請求上一切正常,並且虛擬主機基本相同。

這是我的虛擬主機的相關部分:

<VirtualHost local.domain.com:443>
   DocumentRoot "C:/xampp/htdocs/local"
   ServerName local.domain.com
   ServerAdmin webmaster@localhost
   ErrorLog "logs/error.log"
   <IfModule log_config_module>
       CustomLog "logs/access.log" combined
   </IfModule>
   SSLEngine on
   SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
   SSLCertificateFile "conf/ssl.crt/server.crt"
   SSLCertificateKeyFile "conf/ssl.key/server.key"
   <FilesMatch "\.(cgi|shtml|pl|asp|php)$">
       SSLOptions +StdEnvVars
   </FilesMatch>
   <Directory "C:/xampp/cgi-bin">
       SSLOptions +StdEnvVars
   </Directory>
   BrowserMatch ".*MSIE.*" nokeepalive ssl-unclean-shutdown downgrade-1.0 force-response-1.0
   CustomLog "logs/ssl_request.log" "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
</VirtualHost>

<VirtualHost lmarket.local.domain.com:443>
   DocumentRoot "C:/xampp/htdocs/lmarket.local"
   ServerName lmarket.local.domain.com
   ServerAdmin webmaster@localhost
   ErrorLog "logs/error.log"
   <IfModule log_config_module>
       CustomLog "logs/access.log" combined
   </IfModule>
   SSLEngine on
   SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
   SSLCertificateFile "conf/ssl.crt/server.crt"
   SSLCertificateKeyFile "conf/ssl.key/server.key"
   <FilesMatch "\.(cgi|shtml|pl|asp|php)$">
       SSLOptions +StdEnvVars
   </FilesMatch>
   <Directory "C:/xampp/cgi-bin">
       SSLOptions +StdEnvVars
   </Directory>
   BrowserMatch ".*MSIE.*" nokeepalive ssl-unclean-shutdown downgrade-1.0 force-response-1.0
   CustomLog "logs/ssl_request.log" "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
</VirtualHost>

如果我反轉這些塊,則會發生相反的情況:local.domain.com轉到lmarket.local.domain.com. 任何幫助,將不勝感激。

呃,我找到了答案……不知道為什麼會這樣,但我不得不改變:

<VirtualHost lmarket.local.domain.com:443>

<VirtualHost *:443>

第二個虛擬主機也是如此。希望它可以幫助某人。

您可能忘記告訴 apache 127.0.0.1:443 將用於基於名稱的虛擬主機

NameVirtualHost 127.0.0.1:443

甚至更好

NameVirtualHost *:443

應該在VirtualHost部分之前添加到您的配置中。您還必須VirtualHost使用您輸入的地址更新NameVirtualHost。例如<VirtualHost *:443>

引用自:https://serverfault.com/questions/442515