nginx 获取https 免费证书(最新)

续上次写https获取证书以后 ,现在已经无法使用了

[root@localhost ~]# ./certbot-auto  renew
Upgrading certbot-auto 1.10.1 to 1.11.0...
Couldn't download https://raw.githubusercontent.com/certbot/certbot/v1.11.0/letsencrypt-auto-source/letsencrypt-auto. <urlopen error [Errno 111] Connection refused>

发现报错 Couldn’t download https://raw.githubusercontent.com

原因是:certbot-auto将始终尝试从最新版本中获取自身的最新版本

于是就有了今天这个文章,尝试在官网寻找了最新的certbot来解决证书问题

certbot官网地址:https://certbot.eff.org/

mySystem:Ubuntu16.04系统

获取certbot工具

1.安装snap

介绍

Snap是一个全新的软件包架构,它与其它包管理器的区别在于snap安装的app互相之间是高度隔离的,减少了互相引用. 避免了很多冲突问题. 不过这也导致了其占用的磁盘比较多.

安装

# apt安装
apt install -y snapd snapcraft

# yum安装
# 安装 EPEL
yum install epel-release;
# 安装 snapd
yum install snapd;
# 添加snap启动通信 socket
systemctl enable --now snapd.socket;
# 创建链接(snap软件包一般安装在/snap目录下)
ln -s /var/lib/snapd/snap /snap;

2.安装certbot核心库

sudo snap install core; sudo snap refresh core;

3.安装certbot

sudo snap install --classic certbot

4.添加软链

sudo ln -s /snap/bin/certbot /usr/bin/certbot

5.nginx 添加https

certbot --nginx

使用“certbot --nginx” 来配置https的时候 需要在nginx 里有相关的server配置

server{
        server_name  www.xxxx.com;
        location / {
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;

        client_max_body_size 100M;
        proxy_pass  http://127.0.0.1:9122;
        
        }
}

关于自动续签

由于certbot的免费时间只有90天,所以需要每两个月上去续签一次

参考以前写的 现在改用certbot

#查看SSL证书的过期时间

./certbot-auto certificates 

#更新证书

./certbot-auto renew

#如果不需要返回的信息,可以用静默方式

./certbot-auto renew --quiet

#强制更新证书命令:

./certbot-auto renew --force-renew

#手动更新

./certbot-auto renew -v

#自动更新

./certbot-auto renew --quiet --no-self-upgrade

#定时更新

加入定时任务  crontab -e 

0 3 */15 * * /root/certbot-auto renew --renew-hook "/etc/init.d/nginx reload" >> /root/renew.log

#每十五天的凌晨三点 运行一次更新的脚本,并执行 nginx 重启 并输出日志文件

#我的certbot-auto包是在root目录下的


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值