向导新增第 0d 步:询问宿主机 80 端口是否空闲。
- 空闲(多层代理/内网)→ NGINX_BIND=80,容器直接监听宿主机 80
- 已有 nginx(云服务器 HTTPS)→ NGINX_BIND=127.0.0.1:11223,宿主机加一条转发
docker-compose.yml nginx ports 改用 ${NGINX_BIND:-80}:80 变量控制。
端口检查、Step 7 验证地址、部署完成输出均根据模式动态调整。
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
141 行
3.9 KiB
Markdown
141 行
3.9 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,根据答案自动选择绑定模式:
|
||
|
||
### 场景一:无宿主机 nginx(多层代理 / 内网服务器)
|
||
|
||
容器直接绑定宿主机 `0.0.0.0:80`(`NGINX_BIND=80`),上层 nginx 直接指向本机 IP:
|
||
|
||
```nginx
|
||
location / {
|
||
proxy_pass http://<部署服务器IP>;
|
||
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;
|
||
}
|
||
```
|
||
|
||
### 场景二:宿主机已有 nginx(云服务器域名 HTTPS)
|
||
|
||
容器绑定 `127.0.0.1:11223`(`NGINX_BIND=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;
|
||
}
|
||
```
|
||
|
||
> **两种场景通用**:每一层 nginx 代理都必须加 `proxy_http_version 1.1` 和 `Upgrade`/`Connection` 头,缺少任意一层 IM WebSocket 就会断开。
|
||
|
||
内置 nginx 路由配置在 `config/nginx/conf.d/xuqm.conf`,使用 Docker 服务名路由到各容器,无需关心具体端口。
|
||
|
||
---
|
||
|
||
## 端口说明
|
||
|
||
| 宿主机端口 | 说明 |
|
||
|-----------|------|
|
||
| **80** | 内置 nginx 入口(无宿主机 nginx 场景,`NGINX_BIND=80`) |
|
||
| **11223** | 内置 nginx 入口(有宿主机 nginx 场景,`NGINX_BIND=127.0.0.1:11223`) |
|
||
| 11224–11231 | 各业务容器(绑定 127.0.0.1,调试用) |
|
||
|
||
各业务容器端口仅用于直接调试,正常流量全部走内置 nginx 入口。
|
||
|
||
---
|
||
|
||
## 租户迁移
|
||
|
||
迁移通过一键部署向导完成,选择「迁移租户」后:
|
||
|
||
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
|
||
```
|
||
|
||
已运行的容器不会被重建,数据目录不受影响。
|