2016-07-04 44 views
0

所以我不能讓我的Web服務器與SSL正常工作。我已經搜索了4個小時,試圖讓它起作用,但我沒有運氣。SSL與主要域名不工作,但子域名做

假設我的域名是example.com。

我有一個主站點https://example.com然後我有4個子域1.example,2.example,3.example和4.example。

現在的事情是,我可以訪問所有子域就好了,但是當我嘗試訪問主域時,它說它無法連接到該網站。我究竟做錯了什麼 ??。

在Ubuntu 16.04上使用apache 2.4.20穩定。

下面是使用了virtualhosts配置IM:

<VirtualHost *:443> 

ServerAdmin [email protected] 

LoadModule headers_module modules/mod_headers.so 

DocumentRoot /var/www/example.com 
<Directory /var/www/example.com> 
    Options FollowSymLinks Includes ExecCGI 
    AllowOverride All 
    Require all granted 
    Allow from all 
</Directory> 


ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ 
<Directory "/usr/lib/cgi-bin"> 
    AllowOverride None 
    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch 
    Order allow,deny 
    Allow from all 
</Directory> 

ErrorLog ${APACHE_LOG_DIR}/error.log 

# Possible values include: debug, info, notice, warn, error, crit, 
# alert, emerg. 
LogLevel warn 

RedirectMatch 404 \.token$ 

CustomLog ${APACHE_LOG_DIR}/access.log combined 

SSLEngine on 
SSLCertificateFile /etc/apache2/certs/cert 
SSLCertificateKeyFile /etc/apache2/certs/key 

ServerName www.example.com 

ServerAdmin [email protected] 

LoadModule headers_module modules/mod_headers.so 

DocumentRoot /var/www/1.example.com 
<Directory /var/www/1.example.com> 
    Options FollowSymLinks Includes ExecCGI 
    AllowOverride All 
    Require all granted 
    Allow from all 
</Directory> 


ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ 
<Directory "/usr/lib/cgi-bin"> 
    AllowOverride None 
    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch 
    Order allow,deny 
    Allow from all 
</Directory> 

ErrorLog ${APACHE_LOG_DIR}/error.log 

# Possible values include: debug, info, notice, warn, error, crit, 
# alert, emerg. 
LogLevel warn 

RedirectMatch 404 \.token$ 

CustomLog ${APACHE_LOG_DIR}/access.log combined 

SSLEngine on 
SSLCertificateFile /etc/apache2/certs/cert 
SSLCertificateKeyFile /etc/apache2/certs/key 

ServerName www.1.example.com 

+0

什麼是確切的錯誤信息? – Tom

回答

0

...但是當我嘗試訪問主域名它說它無法連接到該網站。

由於沒有在子域名上運行一個Web服務器,但它說,它無法連接到主站點我的猜測是,您的主要站點有比你的子域不同的IP地址。在這種情況下,Web服務器的配置如何看起來並不重要,因爲它將在不同的IP地址查找Web服務器,而找不到它。

要從客戶端檢查主機的IP地址(只有這一點很重要),您可以在UNIX和Mac上使用dig或nslookup等工具,或者在Windows上使用nslookup。如果您發現您的子域名解析爲與您的主域名不同的IP地址,則可以找到問題的原因。

+0

事實並非如此,我從單個VPS運行eveything,當我關閉SSL時,所有功能都可以正常運行。 – Alexander