2017-09-22 45 views
0

我最近从123-reg.co.uk的旧web服务器移动了一个网站到一个Linode的新Linode网络服务器。Debian 8 - SSL证书不起作用

我使用Debian 8.9运行Apache。

123-reg向我提供了我的网站的SSL证书,当我将网站移动到新的服务器时,该证书被取消激活。所以我开始在我的新服务器上手动重新激活证书。

我能够从123-REG获得必要的SSL文件(CA捆绑,密钥和证书),我跟着的Linode的说明安装使用以下教程自己的服务器上的SSL证书:

First tutorial second tutorial

下面是该网站的配置文件:

<VirtualHost *:80> 
    # All of the files here exist on the server 
    SSLEngine On 
    SSLCertificateFile /etc/ssl/certs/zetec-it.com.crt 
    SSLCertificateKeyFile /etc/ssl/private/zetec-it.com.key 
    SSLCACertificateFile /etc/ssl/certs/ca-certificates.crt 

    ServerAdmin [email protected] 
    ServerName zetec-it.com 
    ServerAlias www.zetec-it.com 

    DirectoryIndex index.html index.php 
    DocumentRoot /var/www/html/zetec-it.com/public_html 
    LogLevel warn 
    ErrorLog /var/www/html/zetec-it.com/log/error.log 
    CustomLog /var/www/html/zetec-it.com/log/access.log combined 
</VirtualHost> 

的设置似乎是合法的,但是当我尝试通过https访问该网站的浏览器指出,连接不牢固。

我对服务器管理员来说相当陌生;有没有人有任何建议或潜在的解决方案?

+1

''你正在绑定你的SSL连接到端口80.你应该使用端口443. –

+0

@JonasSchwabe你是我的上帝英雄,我可以吻你! – AdamMcquiff

+0

@JonasSchwabe奇怪的是,这样做导致我的网站重定向到我的服务器上托管的另一个站点,你知道为什么吗? – AdamMcquiff

回答

1

您需要一个VirtualHost,它正在端口443上侦听,以便使用HTTPS。您将VirtualHost配置为在端口80上侦听,同时具有SSLEngine On

为了获得https工作,您只需要将<VirtualHost *:80>更改为<VirtualHost *:443>。 一旦你这样做了,你就没有处理http连接的配置(没有任何VirtualHost正在等待ServerName zetec-it.com的连接)。

一般有2种方式去服务的HTTP连接请求相同的主机名:使用这样的事情

  1. 您将用户重定向到https(为了使用mod_rewrite重定向到相同的路径):

     
    <VirtualHost *:80> 
        ServerName zetec-it.com 
        ServerAlias www.zetec-it.com 
    
        RewriteEngine on 
        RewriteRule^https://zetec-it.com%{REQUEST_URI} [END,NE,R=permanent] 
    </VirtualHost> 
    
  2. 您可以通过HTTP提供相同的内容,以及

     
    <VirtualHost *:80> 
        # All of the files here exist on the server 
        ServerAdmin [email protected] 
        ServerName zetec-it.com 
        ServerAlias www.zetec-it.com 
    
        DirectoryIndex index.html index.php 
        DocumentRoot /var/www/html/zetec-it.com/public_html 
        LogLevel warn 
        ErrorLog /var/www/html/zetec-it.com/log/error.log 
        CustomLog /var/www/html/zetec-it.com/log/access.log combined 
    </VirtualHost> 
    

无论哪种方式,你需要两个配置文件,https一个(这基本上是你上面的例子,记得用443取代80)和一个给我2个例子的http。 你可以把它们放到单独的文件中,记住在这种情况下激活它们。