美文网首页
Let'Encrypt 免费加密网站 2020

Let'Encrypt 免费加密网站 2020

作者: Codmowa | 来源:发表于2020-05-07 10:49 被阅读0次

准备

  1. 一台Linux 主机, 我的是 Ubuntu16.04
  2. 一个域名.

开始

安装nginx

sudo apt-get install nginx

配置nginx

#新建配置文件, 内容大致如下
server {
    listen 80;
    server_name yourdomain.com; # 替换掉
    rewrite ^(.*)$ https://${server_name}$1 permanent;
} # 80 跳转到443
server {
listen  443 ssl;
keepalive_timeout   70;
server_name yourdomain.com ;
    location / {
        proxy_pass      http://localhost:8080;  # 配置转发到下游
    }
}

安装certbot-auto

 wget https://dl.eff.org/certbot-auto
 chmod a+x ./certbot-auto
 ./certbot-auto

运行certbot-auto nginx 插件

certbot-auto --nginx

根据提示输入相关选项

注意

certbot 会根据nginx 的servername 配置节 自动检测域名
配置完成之后你的域名应该会被自动添加如下配置

ssl_certificate /etc/letsencrypt/live/yourdomain.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/yourdomain.com/privkey.pem; # managed by Certbot

如果是就代表成功了, 如果不是 那么根据错误提示修复之后多来几遍
下一步启用自动更新证书, 通过定时任务来实现

vim cert-renew
# 键入
0 4 */80 * * /path/to/certbot-auto renew &>> /dev/null # 代表每隔80天 凌晨4点更新一次证书
:wq  #保存

最后添加定时任务

crontab cert-renew

引用
https://www.cnblogs.com/ly-radiata/articles/6119374.html
https://certbot.eff.org/docs/using.html#getting-certificates-and-choosing-plugins

相关文章

网友评论

      本文标题:Let'Encrypt 免费加密网站 2020

      本文链接:https://www.haomeiwen.com/subject/nmsoghtx.html