Skip to content
夏天的风
Go back

acme.sh 使用 cloudflare dns 生成证书

1. 安装 acme.sh

服务器终端输入一下命令

curl  https://get.acme.sh | sh -s email=my@example.com

参考 acme.sh 官方文档,可创建一个 alias,方便使用

alias acme.sh=~/.acme.sh/acme.sh

2. 生成证书

获取 cloudflare API key

地址:https://dash.cloudflare.com/profile/api-tokens

设置 cloudflare API key

服务器终端输入一下命令

export CF_Key="cloudflare 中查看你的 key" 
export CF_Email="你的 cloudflare 邮箱"

生成和安装证书

服务器终端输入一下命令

acme.sh --issue -d "yourdomain.com" -d "*.yourdomain.com" --dns dns_cf \
--key-file       /home/ubuntu/ssl/yourdomain.key  \
--fullchain-file /home/ubuntu/ssl/yourdomain.pem \
--reloadcmd "docker restart nginx"

3. 最后

经过以上几步后,acme.sh 会在证书到期前自动更新

移除域名证书自动更新

acme.sh --remove -d yourdomain.com -d "*.yourdomain.com"

参考资料

  1. https://github.com/acmesh-official/acme.sh
  2. https://letsencrypt.org/getting-started/
  3. https://dash.cloudflare.com/profile/api-tokens

Share this post on:

Previous Post
Windows 开发环境配置