2016-07-04 65 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