2017-09-22 52 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。 你可以把它們放到單獨的文件中,記住在這種情況下激活它們。