@lsby/cloudflare-certbot-dns-hook
v0.0.3
Published
方便的对运行在cloudflare上的域名进行certbot-dns挑战.
Readme
cloudflare-certbot-dns-hook
方便的对运行在cloudflare上的域名进行certbot-dns挑战.
安装
npm i -g @lsby/cloudflare-certbot-dns-hook使用
首先您需要保证您的dns解析记录里存在您设置的子域名解析.
例如, 如果您的域名是aaa.com, 您想为bbb.aaa.com这个子域设置ssl证书, 您就必须先手动设置好bbb.aaa.com的解析记录.
接下来安装certbot.
接下来创建两个文件, windows和linux略有不同.
- 文件后缀名不同, windows是
.cmd或.bat, linux是.sh. - 设置环境变量的写法不同, windows是
set, linux是export.
下面的示例使用windows的写法:
auth.cmd:
set CLOUDFLARE_API_TOKEN=<cloudflare的token>
set CLOUDFLARE_ZONE_ID=<cloudflare域名的区域id>
lsby-cloudflare-certbot-dns-hook-authcleanup.cmd:
set CLOUDFLARE_API_TOKEN=<cloudflare的token>
set CLOUDFLARE_ZONE_ID=<cloudflare域名的区域id>
lsby-cloudflare-certbot-dns-hook-cleanup最后执行命令:
certbot certonly --manual --non-interactive --preferred-challenges=dns --manual-auth-hook <auth文件路径> --manual-cleanup-hook <cleanup文件路径> --agree-tos -m <邮箱> -d <完整子域名>- 执行后会卡住很久, 是正常的, 因为要等待dns传播. 现在设置的是等待一分钟.
- 续期时重新执行以上命令即可.
