摘要: 最受欢迎的免费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/…