VPS 科学上网教程 | 05 申请 SSL 证书
VPS 科学上网教程 | 05 申请 SSL 证书
Sarzn使用 acme.sh 通过 Cloudflare DNS 验证方式申请免费的 Let’s Encrypt 证书,支持自动续签。
在 x-ui 面板中也有对域名 SSL 证书的配置,你可以直接去参考视频教程和这个文档 3XUI面板搭建中SSL问题,从而把这一章前面的内容忽略。直接跳到
验证证书文件这一小节。
安装 acme.sh
1 | curl https://get.acme.sh | sh -s email=你的邮箱@example.com |
验证安装:
1 | acme.sh --version |
配置 Cloudflare API Token
将上一步获取的 CF API Token 设置为环境变量:
1 | export CF_Token="你的CloudflareAPIToken" |
CF_Account_ID 在 Cloudflare 控制台右侧边栏可以找到。
申请证书
面板域名
1 | acme.sh --issue --dns dns_cf -d panel.yourdomain.xyz |
代理域名
1 | acme.sh --issue --dns dns_cf -d tunnel.yourdomain.xyz |
申请成功会显示:
1 | Your cert is in: /root/.acme.sh/panel.yourdomain.xyz/panel.yourdomain.xyz.cer |
安装证书到指定目录
1 | mkdir -p /root/cert/panel.yourdomain.xyz |
验证证书文件
1 | ls /root/cert/panel.yourdomain.xyz/ |
每个目录应该包含:
1 | cert.pem |
为面板启用 HTTPS
回到 3x-ui 面板设置,填写证书路径:
| 设置项 | 值 |
|---|---|
| 启用 HTTPS | ✅ 开启 |
| 证书文件路径 | /root/cert/panel.yourdomain.xyz/fullchain.pem |
| 密钥文件路径 | /root/cert/panel.yourdomain.xyz/key.pem |
保存并重启面板,之后面板访问地址变为:
1 | https://panel.yourdomain.xyz:2096/panel |
自动续签
acme.sh 安装后会自动在 crontab 添加续签任务:
通过 3x-ui 面板安装的证书也会自动续签,不用担心
1 | crontab -l |
证书有效期 90 天,acme.sh 会在到期前 30 天自动续签,无需手动操作。
Comment
匿名评论隐私政策
✅ 你无需删除空行,直接评论以获取最佳展示效果



