2016-09-29 124 views
0

我配置了Apache以提供HTTPS請求並將所有HTTP請求重定向到HTTPS。但是......HTTPS請求問題僅限www子域

對於https://www.example.com,Web瀏覽器只是掛起和Apache顯示沒有在日誌,沒有錯誤,沒有訪問。我甚至不確定這是一個Apache問題,我有點失落。任何提示?

我的SSL證書具有CN example.com和我的Apache的配置文件是:

<VirtualHost *:80> 
     ServerName example.com 
     ServerAlias www.example.com 
     DocumentRoot ... 
     Redirect permanent/https://example.com/ 
</VirtualHost> 

<VirtualHost _default_:443> 
     ServerName example.com 
     ServerAlias www.example.com 

     DocumentRoot ...  
     SSLEngine on 
     ...  
</VirtualHost> 
+0

如果您的SSL證書不具有在其鏈中的'www.'域名,虛擬主機的配置將是無效的。 – hjpotter92

+0

奇怪的是,我的CA Gandi指出*「www子域由CA自動添加,例如,example.com將保護example.com和www.example.com。」* – Alphaaa

+0

只有當您的證書是一個通配符。通配符certifciate將保護您設置的任何子域名。 – alejdg

回答

0

Gandi's doc says如果你有一個地址證書激活,如果你與裸域創建CSR(如例子.com),www子域由CA自動添加,例如,example.com將保護example.com和www.example.com。反過來也是如此,如果您使用www子域創建CSR,則裸域也將是安全的。

我只是碰巧產生一個與www.example.com作爲公用名稱,但無論DOC的事情是自動的我就確定包括在.cnf OpenSSL的,我曾經與生成CSR ALT名字說:

[ req ] 
default_md = sha256 
subjectKeyIdentifier=hash 
authorityKeyIdentifier=keyid:always,issuer 
prompt = no 
string_mask = utf8only 
distinguished_name = host_distinguished_name 
req_extensions = host_extensions 

[ host_distinguished_name ] 
commonName = www.example.com 
stateOrProvinceName = Somewhere 
countryName = US 
emailAddress = [email protected] 
organizationName = ACME 

[ host_extensions ] 
subjectAltName = @alt-names 
basicConstraints = CA:false 

[ alt-names ] 
DNS.1 = www.example.com 
DNS.2 = example.com 

生成與一些Debian的私鑰和CSR:

$ subject=www.example.com 
$ openssl genrsa -out ${subject}.key 2048 
$ openssl req -config ${subject}.cnf -new -key ${subject}.key -out ${subject}.csr