Files
youlegames/codes/agent/game-docker/docs/04-ssl.md

69 lines
1.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# SSL 证书管理
使用 Let's Encrypt 免费证书,由 `certbot` 容器自动管理。
---
## 常用命令
```bash
# 首次申请(必须先确保域名已解析)
./deploy.sh ssl-init
# 用测试环境验证(不消耗申请限额)
./deploy.sh ssl-init --staging
# 手动续签
./deploy.sh ssl-renew
# 查看证书状态
./deploy.sh ssl-status
```
`certbot` 容器每 12 小时自动检查续签,证书到期前 30 天自动更新,无需人工干预。
---
## 更换域名后重新申请
更换 `ROOT_DOMAIN` 后需要重新申请证书:
```bash
# 1. 测试验证(不消耗申请限额)
./deploy.sh ssl-init --staging
# 2. 正式申请
./deploy.sh ssl-init
# 3. 重启所有服务
./deploy.sh restart
```
> Let's Encrypt 有频率限制:每 7 天同一域名最多申请 5 次。调试阶段务必用 `--staging` 参数。
---
## 验证文件放置
微信后台添加授权域名时,要求在域名根目录放置 `.txt` 验证文件:
1. 将微信提供的验证文件(如 `MP_verify_xxx.txt`)放入 `api/` 根目录
2. 重建 api 镜像使其生效:
```bash
./deploy.sh rebuild api
```
---
## 数据持久化
SSL 相关的 Docker Volume
| Volume | 挂载点 | 说明 |
|--------|--------|------|
| `certbot-webroot` | /var/www/certbot | ACME 域名验证文件 |
| `certbot-certs` | /etc/letsencrypt | SSL 证书文件 |
> 卸载时若删除 `certbot-certs` volume证书将丢失需重新申请。详见 [卸载和清理](./07-uninstall.md)。