上一篇有提到,可以透過FileZilla的方式把檔案上傳到自己的資料夾中,再透過sudo su成root帳號後,把憑證檔copy或是搬移到指定目錄下。

這次仍然是以我的wordpress為例,如何把申請好的SSL憑證放到GCP裡面,透過HTTPS的方式進行安全瀏覽。

參考資料:Bitnami官方說明文件

1. 首先把憑證檔(我是透過sslforfree網站申請 let’s encrypt所提供的免費憑證)上傳到GCP的個人資料夾中(我自建一個「CA」資料夾)。

2. 透過GCP,開啟瀏覽器的SSH視窗,先輸入「sudo su」切換成root帳號(最高權限)。

sudo su

3. 切換到CA資料夾中,確認憑證上傳無誤。

cd /home/sammy/CA  #sammy代表的是使用者帳號

ls   #ls代表列出該資料夾下所有檔案

黃框代表這個資料夾內的檔案內容

參考Bitnami說明

4. 關於Bitnami的憑證檔的位置,一般來說是在「/opt/bitnami/apache2/conf/」資料夾下,所以要把已經上傳到CA資料夾中的檔案COPY到「/opt/bitnami/apache2/conf/」資料夾中。

cp ca_bundle.crt /opt/bitnami/apache2/conf/    #cp代表copy複製

cp certificate.crt /opt/bitnami/apache2/conf/

cp private.key /opt/bitnami/apache2/conf/

5. 開啟Bitnami的Apache設定檔 位置: /opt/bitnami/apache2/conf/bitnami/bitnami.conf ),修正裡面的憑證名稱。(若是與設定檔的名稱相同則不需修正)

nano /opt/bitnami/apache2/conf/bitnami/bitnami.conf      #nano 修改該檔案內容

6. 若憑證檔有ca_bundle完成的,要補上 SSLCACertificateFile “/opt/bitnami/apache2/conf/server-ca.crt” 字串。

SSLCACertificateFile “/opt/bitnami/apache2/conf/ca_bundle.crt”

#若有ca_bundle的憑證才需加入,留意檔名是否與憑證名稱相同。

參考Bitnami說明

7. 修正完成後按鍵盤上的「Ctrl+O」進行檔案寫出(存檔),確認檔名後直接按Enter鍵即可。

8. 存檔完成後,再按「Ctrl+X」退出。

9. 輸入「sudo /opt/bitnami/ctlscript.sh restart apache」指令重新啟動Apache即可。

sudo /opt/bitnami/ctlscript.sh restart apache   #重新啟動Apache

關閉ssh視窗,直接透過瀏覽器輸入網址後,確認出現綠色鎖頭符號即代表設定完成

設定失敗,則會出現之前這篇文章的情況。

 

[GCP] 在Google Cloud Platform裡使用SSL憑證
Tagged on:                     

2 thoughts on “[GCP] 在Google Cloud Platform裡使用SSL憑證

  • Yody
    2018-01-05 at 4:12 下午
    Permalink

    Hi Sammy,
    我們對您的這篇文章很有興趣,希望有機會能轉載到我們的技術部落格,不知道能不能跟您談授權分享的細節呢? 如果您有興趣的話,歡迎來信到 [email protected],謝謝您,期待收到您的回音 🙂

Comments are closed.