Ubuntu 使用 Certbot 给 Nginx 添加 SSL 证书
Nginx Let's Encrypt HTTPS 大约 878 字关于 Certbot
Certbot
不用注册Let's Encrypt
账号(它会自动帮你注册),不用手动修改配置服务器配置,一行命令搞定。
安装示例
以我的服务器为例(Ubuntu 14.04
)。
首先安装Certbot
。
sudo apt-get update
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:certbot/certbot
sudo apt-get update
sudo apt-get install python-certbot-nginx
安装好后,只需运行一行代码。
sudo certbot --nginx
剩下的一切会自动完成。Certbot
会自动注册账户,检测Nginx
配置文件中的域名,询问为哪些域名生成证书,是否将Http
重定向到Https
等等,最后自动修改Nginx配置并重启,这时网站已经变成了
Https`的了。
另外由于证书只有三个月的有限期,还可以运行以下代码,Certbot
会启动一个定时任务,在证书过期时自动更新。
sudo certbot renew --dry-run
如果只想生成证书,比如七牛云加速域名的证书(Nginx
配置中并没有此域名)。
只需执行以下代码,Certbot
会启动一个临时服务器来完成验证(会占用80
端口或443
端口,因此需要暂时关闭Web
服务器),然后Certbot
会把证书以文件的形式保存,包括完整的证书链文件和私钥文件。
证书默认是在/etc/letsencrypt/live
路径下。
certbot certonly --cert-name example.com
卸载 certbot
apt-get purge software-properties-common
apt-get purge python-certbot-nginx
参考地址
阅读 1057 · 发布于 2021-05-11
————        END        ————
Give me a Star, Thanks:)
https://github.com/fendoudebb扫描下方二维码关注公众号和小程序↓↓↓

昵称:
随便看看
换一批
-
数据结构:双向链表阅读 478
-
Spring Boot 使用 Session 管理登录状态和拦截请求阅读 6516
-
MySQL 行级锁演示阅读 143
-
算法每日一题20190708:合并两个有序链表阅读 1311
-
JMeter 使用 Response Assertion 自定义错误信息阅读 922
-
Linux jobs fg bg disown阅读 1765
-
Java 并发编程之 ConcurrentHashMap 1.8 源码分析阅读 514
-
The temporary upload location [xxxRoot] is not valid阅读 1858
-
GoLand defer 提示 Unhandled error 解决方法阅读 4873
-
OpenResty 整合 LuaRocks - Linux阅读 1434