1. 程式人生 > >Let’s Encrypt 免費 HTTPS 憑證

Let’s Encrypt 免費 HTTPS 憑證

之前架設的 WordPress 只有 http 沒有https, 沒想到居然可以超簡單地就申請好多個 https在同一臺主機。

CertBot真的是很棒的一個網站,會依照不同的作業系統給不同的指令。CertBot滿厲害的,不帶引數,他也可以猜到要產生的domain name,我是透過下面的指令,可以一次加入 2個domain 的 https 憑證到 apache 裡了:

certbot certonly –webroot -w /var/www/example -d example.com

真是太感動了,我的網站也有 https 了。

Automating renewal (自動展期的指令)

Certbot can be configured to renew your certificates automatically before they expire. Since Let’s Encrypt certificates last for 90 days, it’s highly advisable to take advantage of this feature. You can test automatic renewal for your certificates by running this command:

letsencrypt renew –dry-run –agree-tos

如預期,在 Ubuntu 16.04 會多顯示一些錯誤訊息,但不影影展期。

把上面的指令放到排程裡,讓電腦每天自動執行,快到期的時候就會自動展期了。

如果遇到問題,可以點 “Advance” 裡,只使用取得憑證的指令。

有了 letsencrypt 的憑證之後,如果遇到bot 無法自動修改 apache 設定檔的情況,我是都自己修改比較多,請加入下面紅字部份的設定:

<VirtualHost *:443>
    ServerName max-everyday.com
    DocumentRoot /var/www/max-everyday.com/public_html
    ErrorLog /var/log/apache/max-everyday.com/error.log
    CustomLog /var/log/apache/max-everyday.com/access.log combined

	SSLEngine on 
	SSLCertificateFile /etc/letsencrypt/live/max-everyday.com/cert.pem
	SSLCertificateKeyFile /etc/letsencrypt/live/max-everyday.com/privkey.pem
	SSLCertificateChainFile /etc/letsencrypt/live/max-everyday.com/chain.pem
</VirtualHost>

除了免費的 https, 記得網站還要使用免費的CloudFlare CDN,這樣顯示才會「超級快」。

CloudFlare 主要是基於內容傳遞網路(Content Delivery Network, 簡稱 CDN)和分散式網域名稱解析服務(Distributed Domain Name Server)等技術,於世界各地分佈超過三十個資料中心,當使用者連線到使用 CloudFlare 服務的網站後,會從最接近使用者的資料中心來接收網站內容,以加快網站載入速度。

CloudFlare 提供網站基本安全防護功能,將真實伺服器 IP 位址隱藏在 CF 伺服器後,避免伺服器被攻擊、入侵或對網站造成危害,加速以外更增添了安全性。

以上2點都是 CloudFlare 免費方案的功能,若你想得到更多的可自訂專案,或是增加連線的速度和安全防護效能,也可考慮付費來升級為 Pro 或 Business 等高階方案。

相關文章: