摘要: 最受歡迎的免費HTTPS證書,瞭解一下?python
本文的操做是在Ubuntu 16.04下進行,使用nginx做爲Web服務器。nginx
Certbot能夠用於管理(申請、更新、配置、撤銷和刪除等)Let's Encrypt證書。這裏安裝的是帶nginx插件的certbot:ubuntu
sudo apt-get update
sudo apt-get install software-properties-common
sudo add-apt-repository -y ppa:certbot/certbot
sudo apt-get update
sudo apt-get install -y python-certbot-nginx
複製代碼
vim /etc/nginx/conf.d/fundebug.conf
複製代碼
此時尚未HTTPS證書,所以域名只能使用80端口而非443端口,網站只能經過http協議而非https協議訪問:www.fundebug.com。小程序
server
{
listen 80;
server_name www.fundebug.com;
}
複製代碼
重啓nginx:vim
systemctl restart nginx
複製代碼
使域名www.fundebug.com指向nginx所在服務器的IP:微信小程序
若是你想發現代碼中隱藏的BUG,歡迎免費試用最專業的BUG實時監控平臺Fundebug!bash
使用certbot命令爲www.fundebug.com申請HTTPS證書。--nginx選項表示Web服務器爲nginx,-d選項指定域名,-n選項表示非交互式運行命令。若去除**-n**選項,則終端會提醒你選擇是否將http請求重定向爲https請求。服務器
certbot --nginx -d www.fundebug.com -n
複製代碼
證書申請成功以後,會看到如下信息。Let's Encrypt證書的有效期只有3個月,可是Certbot會經過Cron和systemd timer自動更新證書,證書的時效性不用擔憂。微信
IMPORTANT NOTES:
- Congratulations! Your certificate and chain have been saved at:
/etc/letsencrypt/live/www.fundebug.com/fullchain.pem
Your key file has been saved at:
/etc/letsencrypt/live/www.fundebug.com/privkey.pem
Your cert will expire on 2018-09-29. To obtain a new or tweaked
version of this certificate in the future, simply run certbot again
with the "certonly" option. To non-interactively renew *all* of
your certificates, run "certbot renew"
- If you like Certbot, please consider supporting our work by:
Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate Donating to EFF: https://eff.org/donate-le 複製代碼
HTTPS證書相關的文件在**/etc/letsencrypt/**目錄中:app
find /etc/letsencrypt/ -name "*www.fundebug.com*"
/etc/letsencrypt/renewal/www.fundebug.com.conf
/etc/letsencrypt/archive/www.fundebug.com
/etc/letsencrypt/live/www.fundebug.com
複製代碼
certbot會自動修改nginx配置文件:
cat /etc/nginx/conf.d/fundebug.conf
複製代碼
nginx監聽了443端口並配置了HTTPS證書,這時咱們能夠經過HTTPS協議訪問了!www.fundebug.com
server
{
listen 80;
server_name www.fundebug.com;
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/www.fundebug.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/www.fundebug.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
複製代碼
Fundebug專一於JavaScript、微信小程序、微信小遊戲、支付寶小程序、React Native、Node.js和Java線上應用實時BUG監控。 自從2016年雙十一正式上線,Fundebug累計處理了10億+錯誤事件,付費客戶有Google、360、金山軟件、百姓網等衆多品牌企業。歡迎你們免費試用!
轉載時請註明做者Fundebug以及本文地址:
blog.fundebug.com/2018/07/06/…