差異處
這裏顯示兩個版本的差異處。
下次修改 | 前次修改 | ||
pc:mixed:sslwithletsencrypt [2017/02/27 18:52] tony 建立 |
pc:mixed:sslwithletsencrypt [2023/06/25 09:48] (目前版本) |
||
---|---|---|---|
行 1: | 行 1: | ||
+ | {{tag>https lets_encrypt}} | ||
====== Let's Encrypt ====== | ====== Let's Encrypt ====== | ||
===== Introduction ===== | ===== Introduction ===== | ||
原先我使用StartSSL的免費Certificate在我的web server上,後來因為此篇[[http://www.ithome.com.tw/news/108698|新聞]]的原因,導致我需要找新的方法。Let's Encrypt是Linux基金會託管項目,雖然每次證書只有三個月的效用,但可解我燃眉之急。 | 原先我使用StartSSL的免費Certificate在我的web server上,後來因為此篇[[http://www.ithome.com.tw/news/108698|新聞]]的原因,導致我需要找新的方法。Let's Encrypt是Linux基金會託管項目,雖然每次證書只有三個月的效用,但可解我燃眉之急。 | ||
===== How to? ===== | ===== How to? ===== | ||
- | 我參考了[[https://blog.gtwang.org/linux/secure-nginx-with-lets-encrypt-ssl-certificate-on-ubuntu-and-debian|此篇教學]]後,遇到第一個問題是驗證失敗:\\ | + | ==== 無法啟動httpd的問題 ==== |
- | + | 我參考了[[https://blog.gtwang.org/linux/secure-nginx-with-lets-encrypt-ssl-certificate-on-ubuntu-and-debian|此篇教學]]。cerbot這隻程式將一切過程變得相當容易,首先下載cerbot: | |
- | + | <code bash> | |
+ | mkdir /opt/cerbot | ||
+ | cd /opt/cerbot | ||
+ | wget https://dl.eff.org/certbot-auto | ||
+ | chmod a+x certbot-auto | ||
+ | </code> | ||
+ | 接著就是使用管理權限執行cerbot,而我遇到的問題是驗證失敗,這是由於驗證伺服器無法連接到我伺服器而造成的。原因是httpd啟動失敗:\\ | ||
+ | {{:pc:mixed:lets_encrypt_httpd_start_failed.png|}}\\ | ||
+ | 這是由於cerbot自動產生一個ssl設定到httpd/conf下,與原本的衝突導致的;於是我註解原本的ssl設定後,就可以正常啟動httpd。最後重新執行certbot,按照指示做重新啟動httpd即可獲得可信任的certificate。\\ | ||
+ | \\ | ||
+ | 由於它是3個月一簽,透過crontab去幫我們自動更新會比較方便,可以透過以下腳本進行更新: | ||
+ | <code bash> | ||
+ | #!/bin/bash | ||
+ | /opt/cerbot/cerbot-auto renew --quiet --no-self-upgrade --post-hook "service httpd reload" | ||
+ | </code> | ||
+ | 在更新後,透過posthook去重新載入httpd設定。crontab設定方法可以參考此[[http://serverfault.com/questions/790772/cron-job-for-lets-encrypt-renewal|link]]。 | ||
+ | ==== 多個domain的問題 ==== | ||
+ | 在完成上面步驟後,我發現www.tonylin.idv.tw可以正常使用,而tonylin.idv.tw不行。後來得知可以透過以下指令擴展domain名稱: | ||
+ | <code bash> | ||
+ | ./certbot-auto -d www.tonylin.idv.tw -d tonylin.idv.tw | ||
+ | </code> | ||
+ | 在執行時,它會問你要擴展還是取代原本的,選擇擴展即可:\\ | ||
+ | {{:pc:mixed:letsecrypt_extend_multi_domain.png|}}\\ | ||
+ | 最後重新載入httpd即完成。 | ||
===== Reference ===== | ===== Reference ===== | ||
* [[https://scheng.tk/blog/1066/8-free-ssl|8個免費SSL證書]] | * [[https://scheng.tk/blog/1066/8-free-ssl|8個免費SSL證書]] | ||
* [[https://blog.gtwang.org/linux/secure-nginx-with-lets-encrypt-ssl-certificate-on-ubuntu-and-debian/|NGINX 使用 Let’s Encrypt 免費 SSL 憑證設定 HTTPS 安全加密網頁教學]] | * [[https://blog.gtwang.org/linux/secure-nginx-with-lets-encrypt-ssl-certificate-on-ubuntu-and-debian/|NGINX 使用 Let’s Encrypt 免費 SSL 憑證設定 HTTPS 安全加密網頁教學]] | ||
* [[http://www.linuxquestions.org/questions/linux-server-73/apache-won't-start-module-ssl_module-is-already-loaded-fixed-700972/|Apache Httpd無法載入SSL模組的問題]] | * [[http://www.linuxquestions.org/questions/linux-server-73/apache-won't-start-module-ssl_module-is-already-loaded-fixed-700972/|Apache Httpd無法載入SSL模組的問題]] | ||
+ | * [[https://community.letsencrypt.org/t/certificate-valid-for-non-www-and-www-as-well/3725/4|如何讓www與non-www的certificate可同時使用]] | ||
+ | ===== ===== | ||
+ | ---- | ||
+ | \\ | ||
+ | ~~DISQUS~~ |