将 nginx 容器从可选 profile 改为 base 必启服务,绑定 127.0.0.1:11223。 新增 config/nginx/conf.d/xuqm.conf 按 Docker 服务名路由所有内部请求。 部署完成提示从多条 location 精简为单条 proxy_pass http://127.0.0.1:11223。 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
121 行
3.0 KiB
Markdown
121 行
3.0 KiB
Markdown
# 私有化部署运行手册
|
||
|
||
## 一键部署
|
||
|
||
```bash
|
||
curl -fsSL https://xuqinmin.com/xuqmGroup/XuqmGroup-PrivateDeploy/raw/branch/main/install.sh \
|
||
-o install.sh && bash install.sh
|
||
```
|
||
|
||
交互式向导依次完成:
|
||
|
||
1. 选择租户初始化方式(新建 / 迁移)
|
||
2. 填写租户信息或迁移密钥
|
||
3. 填写外部访问地址(宿主机 nginx 对外的地址,用于 SDK 配置)
|
||
4. 自动完成容器启动、数据库初始化、全量验证
|
||
|
||
完成后按输出的端口表配置宿主机 nginx。
|
||
|
||
---
|
||
|
||
## Nginx 配置
|
||
|
||
部署内置了一个 nginx 容器处理所有内部路由,对外只暴露 `127.0.0.1:11223`。
|
||
|
||
宿主机 nginx 的 server 块内只需加一条:
|
||
|
||
```nginx
|
||
location / {
|
||
proxy_pass http://127.0.0.1:11223;
|
||
proxy_http_version 1.1;
|
||
proxy_set_header Upgrade $http_upgrade;
|
||
proxy_set_header Connection "upgrade";
|
||
proxy_set_header Host $host;
|
||
proxy_set_header X-Real-IP $remote_addr;
|
||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||
proxy_read_timeout 3600s;
|
||
}
|
||
```
|
||
|
||
> `proxy_http_version 1.1` 和 `Upgrade`/`Connection` 头是 WebSocket(IM)必需的,不能省略。
|
||
|
||
内置 nginx 路由配置在 `config/nginx/conf.d/xuqm.conf`,使用 Docker 服务名路由到各容器,无需关心具体端口。
|
||
|
||
---
|
||
|
||
## 端口说明
|
||
|
||
| 宿主机端口 | 说明 |
|
||
|-----------|------|
|
||
| **11223** | 内置 nginx 入口(宿主机 nginx 指向此端口) |
|
||
| 11224–11231 | 各业务容器(绑定 127.0.0.1,调试用) |
|
||
|
||
各业务容器端口仅用于直接调试,正常流量全部走 11223。
|
||
|
||
---
|
||
|
||
## 租户迁移
|
||
|
||
迁移通过一键部署向导完成,选择「迁移租户」后:
|
||
|
||
1. 前往公有化平台控制台 → 安全中心 → 私有化部署迁移 → 生成迁移密钥
|
||
2. 将 `pmk_` 开头的密钥粘贴进向导
|
||
3. 脚本自动导出租户数据、导入私有库、写入 license 记录、重启服务
|
||
|
||
迁移为单租户操作,会清空现有 bootstrap 数据后写入迁移数据。
|
||
|
||
---
|
||
|
||
## 常用运维命令
|
||
|
||
```bash
|
||
# 查看所有容器状态
|
||
docker compose -f docker-compose.yml -f docker-compose.infra.yml ps
|
||
|
||
# 查看服务日志
|
||
docker compose -f docker-compose.yml -f docker-compose.infra.yml logs --tail 100 tenant-service
|
||
|
||
# 重新运行全量验证
|
||
bash scripts/verify.sh
|
||
|
||
# 停止所有服务(保留数据)
|
||
docker compose -f docker-compose.yml -f docker-compose.infra.yml down
|
||
|
||
# 启用可选服务
|
||
bash scripts/enable-service.sh im
|
||
|
||
# 禁用可选服务(不删数据)
|
||
bash scripts/disable-service.sh im
|
||
|
||
# 备份数据
|
||
bash scripts/backup.sh
|
||
|
||
# 恢复数据
|
||
bash scripts/restore.sh <backup-file>
|
||
```
|
||
|
||
---
|
||
|
||
## 数据目录
|
||
|
||
| 路径 | 说明 |
|
||
|------|------|
|
||
| `data/mysql/` | MySQL 数据文件 |
|
||
| `data/redis/` | Redis AOF 文件 |
|
||
| `data/uploads/` | 文件服务上传目录 |
|
||
| `data/update/` | 版本管理包存储 |
|
||
| `data/backups/` | 备份文件 |
|
||
| `logs/` | 审计日志 |
|
||
|
||
---
|
||
|
||
## 重新部署(幂等)
|
||
|
||
脚本幂等,可重复执行:
|
||
|
||
```bash
|
||
bash install.sh
|
||
```
|
||
|
||
已运行的容器不会被重建,数据目录不受影响。
|