教你快速撸一个免费HTTPS证书

简介: 摘要: 免费 HTTPS 证书,了解一下? HTTPS 已成为业界标准,这篇博客将教你申请Let's Encrypt的免费 HTTPS 证书。 本文的操作是在 Ubuntu 16.04 下进行,使用 nginx 作为 Web 服务器。

摘要: 免费 HTTPS 证书,了解一下?

HTTPS 已成为业界标准,这篇博客将教你申请Let's Encrypt的免费 HTTPS 证书。

本文的操作是在 Ubuntu 16.04 下进行,使用 nginx 作为 Web 服务器。

1. 安装 Certbot

Certbot可以用于管理(申请、更新、配置、撤销和删除等)Let's Encrypt 证书。这里安装的是带 nginx 插件的 certbot:

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

2. 配置 Nginx

vim /etc/nginx/conf.d/fundebug.conf

此时还没有 HTTPS 证书,因此域名只能使用 80 端口而非 443 端口,网站只能通过 http 协议而非 https 协议访问:http://www.fundebug.com

server
{
    listen 80;
    server_name www.fundebug.com;
}

重启 nginx:

systemctl restart nginx

3. 配置 DNS

使域名www.fundebug.com指向 nginx 所在服务器的 IP:

如果你想发现代码中隐藏的 BUG,欢迎免费试用最专业的 BUG 实时监控平台Fundebug!

4. 申请证书

使用 certbot 命令为www.fundebug.com申请 HTTPS 证书。--nginx选项表示 Web 服务器为 nginx,-d选项指定域名,-n选项表示非交互式运行命令。若去除-n选项,则终端会提醒你选择是否将 http 请求重定向为 https 请求。

certbot --nginx -d www.fundebug.com -n --email help@fundebug.com --agree-tos

证书申请成功之后,会看到以下信息。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/目录中:

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 协议访问了!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

Fundebug专注于JavaScript、微信小程序、微信小游戏、支付宝小程序、React Native、Node.js和Java线上应用实时BUG监控。 自从2016年双十一正式上线,Fundebug累计处理了10亿+错误事件,付费客户有Google、360、金山软件、百姓网等众多品牌企业。欢迎大家免费试用

版权声明

转载时请注明作者Fundebug以及本文地址:
https://blog.fundebug.com/2018/07/06/apply-lets-encrypt-certificate/

目录
相关文章
|
5月前
|
算法 Linux 网络安全
Centos7 Linux系统下生成https的crt和key证书
Centos7 Linux系统下生成https的crt和key证书
193 0
|
5月前
|
安全 算法 小程序
互联网并发与安全系列教程(17) - 生产环境配置HTTPS证书
互联网并发与安全系列教程(17) - 生产环境配置HTTPS证书
73 0
|
7月前
|
域名解析 缓存 网络协议
Let's Encrypt 配置 HTTPS 免费泛域名证书
Let's Encrypt 配置 HTTPS 免费泛域名证书
909 0
|
17天前
|
域名解析 网络协议 应用服务中间件
阿里云SSL证书配置(HTTPS证书配置)
该内容是一个关于如何在阿里云上准备和购买SSL证书,以及如何为网站启用HTTPS的步骤指南。首先,需要注册并实名认证阿里云账号,然后在SSL证书控制台选择证书类型、品牌和时长进行购买。申请证书时填写域名信息,并进行DNS验证,这包括在阿里云域名管理板块添加解析记录。完成验证后提交审核,等待证书审核通过并下载Nginx格式的证书文件。最后,将证书配置到网站服务器以启用HTTPS。整个过程涉及账户注册、实名认证、证书购买、DNS设置和证书下载及安装。
86 0
|
21天前
|
网络安全 数据安全/隐私保护 Docker
免费的HTTPS证书
免费的HTTPS证书
66 1
|
1月前
|
存储 网络安全 数据安全/隐私保护
Windows Server 2019 IIS HTTPS证书部署流程详解
Windows Server 2019 IIS HTTPS证书部署流程详解
|
1月前
|
安全 网络安全 CDN
阿里云CDN HTTPS 证书配置流程
阿里云CDN HTTPS 证书配置流程
172 1
|
7月前
|
安全 应用服务中间件 Linux
Linux安装免费Https证书,过期自动更新 省钱秘籍
Linux安装免费Https证书,过期自动更新 省钱秘籍