saber 酱的抱枕

Fly me to the moon

12/3
2020
软件

certbot 在 nginx 上创建 https 证书

三月之期已到,又到了折腾 https 证书的时候了。

今天去 certbot 官网看了看文档,发现了个好用的方法。

https://certbot.eff.org/docs/using.html#nginx

对于 nginx 服务器,只需执行 certbot --nginx 就能方便的创建 https 证书。

执行 certbot --nginx,首先会列出 nginx 管理的网站列表,让你选择要为哪些网站建立证书:

certbot 在 nginx 上创建 https 证书

如果不输入网站编号就直接回车,会选择所有网站。也可以输入单个或多个编号,用逗号分割。

如果某些网站已经有了证书,会询问你是否替换已有证书:

certbot 在 nginx 上创建 https 证书

证书创建成功后,会询问你是否让访问 http 的请求自动跳转到 https。

certbot 在 nginx 上创建 https 证书

这个如果自己在 nginx 配置文件里做过配置,就选择 1 不进行操作。如果没有配置过就选择 2 让 certbot 自动配置。

执行完毕之后,重启 nginx 就可以生效了,挺方便的。

三个月之后续期的时候再试试 certbot renew 能不能正常运行吧。

certbot 在 nginx 上创建 https 证书