Bladeren bron

add certbot.md

joe 4 jaren geleden
bovenliggende
commit
ffa3ec7587
3 gewijzigde bestanden met toevoegingen van 96 en 8 verwijderingen
  1. 9 8
      README.md
  2. 87 0
      content/posts/certbot.md
  3. 0 0
      githublog.py

+ 9 - 8
README.md

@@ -1,11 +1,3 @@
-## posts
-
-- [beanstalkd 任务队列](http://git.wanbits.io/joe/blog/src/master/content/posts/beanstalkd.md)
-- [mustache 模板引擎中文文档](http://git.wanbits.io/joe/blog/src/master/content/posts/mustache.md)
-- [mysql commands](http://git.wanbits.io/joe/blog/src/master/content/posts/daily-mysql.md)
-- [环境变量配置](http://git.wanbits.io/joe/blog/src/master/content/posts/env.md)
-- [git in real world](http://git.wanbits.io/joe/blog/src/master/content/posts/git-in-real-world.md)
-
 ## res
 
 - [在线文档和书籍](http://git.wanbits.io/joe/blog/src/master/content/res/docs_or_books.md)
@@ -13,3 +5,12 @@
 - [好网站 一辈子](http://git.wanbits.io/joe/blog/src/master/content/res/best-sites.md)
 - [临时性文章 read it later](http://git.wanbits.io/joe/blog/src/master/content/res/temp_articles.md)
 
+## posts
+
+- [certbot nginx ssl 证书管理](http://git.wanbits.io/joe/blog/src/master/content/posts/certbot.md)
+- [beanstalkd 任务队列](http://git.wanbits.io/joe/blog/src/master/content/posts/beanstalkd.md)
+- [mustache 模板引擎中文文档](http://git.wanbits.io/joe/blog/src/master/content/posts/mustache.md)
+- [mysql commands](http://git.wanbits.io/joe/blog/src/master/content/posts/daily-mysql.md)
+- [git in real world](http://git.wanbits.io/joe/blog/src/master/content/posts/git-in-real-world.md)
+- [环境变量配置](http://git.wanbits.io/joe/blog/src/master/content/posts/env.md)
+

+ 87 - 0
content/posts/certbot.md

@@ -0,0 +1,87 @@
+---
+title: "certbot nginx SSL 证书管理"
+date: 2021-09-29T00:37:08+07:00
+draft: false
+---
+
+## HTTPS 证书
+
+现在很多站的 HTTPS 使用的是 Lets Encrypt 颁发的免费证书,证书 90 天过期,自动续期基本往往都会出现问题导致不能真正的自动续期。甚至后来的手动续期也会有各种各样的问题。比如 
+
+```shell
+Your system is not supported by certbot-auto anymore.
+```
+
+## 一般性方法
+
+我推荐到 Let's Encrypt 的官方网站上参看指导方案解决。
+
+打开网站[https://certbot.eff.org/lets-encrypt/snap-nginx](https://certbot.eff.org/lets-encrypt/snap-nginx),从页面中找到 My HTTP website is running () on () 这句话,从下拉列表中选择自己的 web 服务器类型和操作系统或这使用的管理工具。
+
+本篇文章就是这个页面的中文翻译,对应  My HTTP website is running (nginx) on (pip)。我的 server 是 Debian9,考虑到 pip 这个解决方案可能有更好的通用性。
+
+## 使用 pip3 管理证书
+
+1. 首先更新
+
+```shell
+$ sudo apt updte
+$ sudo apt install python3 python3-venv libaugeas0
+```
+
+2. 卸载旧版本 certbot
+
+```shell
+$ sudo apt remove certbot
+```
+
+3. 建立 Python 虚拟环境
+
+```shell
+$ sudo python3 -m venv ./certbot
+$ cd certbot
+$ source bin/activate
+$ pip install --upgrade pip
+```
+
+4. 安装 certbot
+
+```shell
+$ pip installl certbot certbot-nginx
+$ ln -s ./bin/certbot ./certbot
+```
+
+5. 安装颁发证书
+
+- 一步到位执行
+```shell
+$ sudo certbot --nginx
+```
+
+- 手动管理 nginx .well_known 等
+```shell
+$ sudo certbot certonly --nginx
+```
+
+6. 设置自动续期
+在 /etc/crontab 中追加
+
+```shell
+$ echo "0 0,12 * * * root /opt/certbot/bin/python -c 'import random; import time; time.sleep(random.random() * 3600)' && certbot renew -q" | sudo tee -a /etc/crontab > /dev/null
+```
+
+纯测试可运行
+
+```shell
+$ sudo certbot renew --dry-run
+```
+
+7. 更新 certbot
+
+在 3 中的虚拟环境中执行
+```shell
+$ sudo pip3 --upgrade certbot certbot-nginx
+```
+出错的话删掉虚拟环境重装。
+
+原文链接 [https://certbot.eff.org/lets-encrypt/pip-nginx](https://certbot.eff.org/lets-encrypt/pip-nginx)

+ 0 - 0
githublog.py