Caddy2 申请腾讯云SSL证书

s );
}ccaddii

caddy的证书nginx的 ssl证书配置不一样

配置过程比较复杂

第一步: 安装Caddy(CentOS 8.x)

dnf install 'dnf-command(copr)'
dnf copr enable @caddy/caddy
dnf install caddy

第二步:修改默认访问页面 启动服务

mkdir /opt/web -p
echo "<h1>Hello Caddy</h1>" > /opt/web/index.html

vi /etc/caddy/Caddyfile
www.sh-investment.xyz:80 {
        encode gzip
        file_server {
            root  /opt/web
            index index.html
        }
}

systemctl enable --now caddy

 第三步 实现https访问

安装dnspod包:caddy add-package github.com/caddy-dns/dnspod

安装申请证书脚本

curl https://get.acme.sh | sh

OK, Close and reopen your terminal to start using acme.sh
Installing alias to '/root/.cshrc'
Installing alias to '/root/.tcshrc'
Installing cron job
Good, bash is found, so change the shebang to use bash as preferred.
OK
Install success!

安装提示成功(网络原因 需要多次尝试才会成功)

注册邮箱  ./acme.sh --register-account -m l.hao.2012@qq.com

成功后修改Caddyfile配置后保存

www.sh-investment.xyz:443 {
        encode gzip
        file_server {
            root  /opt/web
            index index.html
        }
        tls l.hao.2012@qq.com
}

获取腾讯的dnspod的token

 申请证书

export DP_Id="307280"
export DP_Key="abe5f00be2f8e7cbd0cd"

 ./acme.sh --issue  --dns dns_dp -d www.sh-investment.xyz


Your cert is in: /root/.acme.sh/www.sh-investment.xyz/www.sh-investment.xyz.cer
Your cert key is in: /root/.acme.sh/www.sh-investment.xyz/www.sh-investment.xyz.key
The intermediate CA cert is in: /root/.acme.sh/www.sh-investment.xyz/ca.cer
And the full chain certs is there: /root/.acme.sh/www.sh-investment.xyz/fullchain.cer

 证书申请成功(也是多次尝试才会成功 出现手动dns验证提示需要在控制台中需加入一条txt验证)

caddy reload 重新加载配置

访问测试

 相比nginx Caddy2在证书配置方面 还是比较复杂的

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

恒云客

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值