惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - SKILL·NULL

如何为GIT设置全局勾子,为每次提交追加信息 - SKILL·NULL 一文了解大模型、小模型与各类神经网络的关系 如何在Mac上调整外星人鼠标AW720M的灯光颜色 Karabiner-Elements最常用配置 IndexedDB封装 echarts获取坐标上的点距离顶部底部高度 H5滚动截取长图 ReactNative常见问题及处理 根据.nvmrc自动切换项目所需node版本 Command PhaseScriptExecution failed with a nonzero exit code echarts双Y轴,实现均分为包含刻度0的指定段数,同时对齐刻度 env(safe-area-inset-bottom) 兼容写法 缩放实现0.5px 禁止 IOS 橡皮筋效果 JS 拦截浏览器返回 海康威视DS-IPC-E42H-IWPT监控画面竖线处理 Echarts 5 动态按需引入图表 React 18 自定义 Hook 获取 useState 最新值 处理报错 ResizeObserver loop completed with undelivered notifications.
Let`s Encrypt 生成免费自动续签 HTTPS 证书
SKILL·NULL · 2025-11-04 · via 博客园 - SKILL·NULL

Let`s Encrypt  是一个免费的证书授权机构(CA),其通过 ACME 协议接口自动签发数字证书,来让你省去证书过期的烦恼。

ACME客户端有很多,Let`s Encrypt 官网推荐  Certbot  ,下面是具体获取免费证书的流程:

一、安装 Certbot 客户端

yum install certbot

二、生成证书

certbot certonly --webroot -w /your/site/root -d yoursite.com -d

上述命令会为 yoursite.com 和 www.yoursite.com 这两个域名生成证书,使用 --weroot 模式会在 /your/site/root 中创建 .well-known 文件夹,这个文件夹里面包含了一些验证文件,certbot 会通过访问 yoursite.com/.well-known/acme-challenge 来验证你的域名是否绑定的这个服务器。

生成的证书会被放置在 /etc/letsencrypt/live/yoursite.com/ 目录下。我们要用到的有两个 fullchain.pem 和 privkey.pem

三、配置证书

在 nginx 配置对证书:

server {
  server_name yoursite.com www.yoursite.com;
  listen 443;
  ssl_certificate /etc/letsencrypt/live/yoursite.com/fullchain.pem;
  ssl_certificate_key /etc/letsencrypt/live/yoursite.com/privkey.pem;
}

四、自动更新 SSL 证书

Let’s Encrypt 提供的证书只有90天的有效期,我们必须在证书到期之前,重新获取这些证书,certbot 给我们提供了一个很方便的命令,那就是 certbot renew。 通过这个命令,他会自动检查系统内的证书,并且自动更新这些证书:

certbot renew --dry-run

上述命令需要手动在证书到期前执行,来更新证书。为了更方便,我们可以启动一个定时任务,来完成自动更新。

CentOS 7 上设置定时任务有多种方式,如:crontab、systemd timer、at等。本文采用crontab。

我们设置每隔两个月执行一次更新命令,并重启 nginx。首先看下 crontab 任务格式:

* * * * * command

其中,五个星号分别代表分钟、小时、日、月、周,可以使用以下符号:

*: 代表任意值

,:代表多个值

-:代表一个范围

/:代表间隔时间

所以我们的命令如下:

0 3 4 */2 * certbot renew --post-hook "nginx -s reload" >> /var/log/certbot-renew.log 2>&1

上述命令表示,每隔两个月的4号凌晨3点,重新执行cerbot证书续期命令,执行完后重启nginx,并生成日志;

下面是具体设置定时任务步骤:

1、执行命令 crontab -e

2、输入命令  0 3 4 */2 * certbot renew --post-hook "nginx -s reload" >> /var/log/certbot-renew.log 2>&1 

保存并退出。

系统提示:

no crontab for root - using an empty one
crontab: installing new crontab

表示定时任务设置成功!

可以通过 crontab -l 来查看定时任务是否设置成功。