This commit is contained in:
vet
2026-04-20 17:26:25 +07:00
parent fa6b610ddf
commit 83d425b182
8 changed files with 27 additions and 87 deletions

View File

@@ -103,7 +103,6 @@ deploy-test/
./deploy-test/dt.sh stop # 停止 deploy-test 后端服务
./deploy-test/dt.sh restart # 重启 deploy-test 后端服务
./deploy-test/dt.sh status # 查看服务状态
./deploy-test/dt.sh pc-build # 构建 PC Web 静态产物到 /app/pc/dist
./deploy-test/dt.sh fe-start pc # 启动 pc 前端
./deploy-test/dt.sh fe-stop pc # 停止 pc 前端
./deploy-test/dt.sh up # pull + build + restart
@@ -308,26 +307,26 @@ TENCENT_SDK_SECRET_KEY=xxx
### Nginx 反代(域名 HTTPS 入口,供 PC / 浏览器访问后端)
在**测试服务器**上部署 Nginx本机 Nginx 仅监听 HTTP `:80`直接访问 PC 构建产物 `/app/pc/dist`,并反代 OpenIM API、chat-api 与 MsgGateway WebSocket。外部访问仍使用 `https://cms-jack.imharry.work`HTTPS 由外层 LB/CDN/其它网关终止后转发到本机 `:80`
在**测试服务器**上部署 Nginx本机 Nginx 仅监听 HTTP `:80`统一反代 PC Vite dev:web server、OpenIM API、chat-api 与 MsgGateway WebSocket。外部访问仍使用 `https://cms-jack.imharry.work`HTTPS 由外层 LB/CDN/其它网关终止后转发到本机 `:80`
| 路径前缀 | 后端 |
|----------|------|
| `/api/im/` | `127.0.0.1:10002` |
| `/api/user/``/api/chat/` | `127.0.0.1:10008` |
| `/msg_gateway` | `127.0.0.1:10001`WebSocket |
| `/` | `/app/pc/dist`PC Web 静态构建产物 |
| `/` | `127.0.0.1:5173`PC Vite dev:web server |
1. 服务器上已执行 `05-start.sh` 等,保证 `10001/10002/10008` 在监听。
2. 域名 `cms-jack.imharry.work` 已解析到测试服务器公网 IP。
3. `.env.deploy-test` 中设置 **`PC_BACKEND_ORIGIN=https://cms-jack.imharry.work`**(无末尾 `/`)。
4. 仓库根目录执行:`./deploy-test/08-build-pc.sh``./deploy-test/dt.sh pc-build`,构建 `/app/pc/dist`
4. 仓库根目录执行:`./deploy-test/07-start-frontend.sh pc``./deploy-test/dt.sh fe-start pc`,启动 PC Vite dev:web server
5. 仓库根目录执行:`sudo ./deploy-test/00-init-tools.sh nginx`(会安装 `nginx`,并写入配置 `deploy-test/nginx/openim-pc-proxy.conf`;亦已包含在 `00-init-tools.sh` 无参的 **all** 流程末尾,需 root
6. 测试服务器本机/安全组放行 **TCP 80**;外层 LB/CDN/网关对公网提供 HTTPS `443` 并转发到本机 `80`
7. 浏览器打开 **`https://cms-jack.imharry.work/`**。
**域名访问**:本配置中 `openim-pc-proxy` 使用 `server_name cms-jack.imharry.work`,只监听本机 `80`;推荐外部 `GET /``https://cms-jack.imharry.work/`,由外层 HTTPS 入口转发到本机 `80`读取 `/app/pc/dist``00-init-tools.sh nginx` 会禁用 `sites-enabled/default`,并尝试去掉 `sites-available/default` 里的 `default_server`,避免默认站点抢占 `:80`。若机上还有其它站点也写了 `default_server``nginx -t` 会报错,需在该站点配置中删除 `default_server`(保留 `listen 80;` 即可)。
**域名访问**:本配置中 `openim-pc-proxy` 使用 `server_name cms-jack.imharry.work`,只监听本机 `80`;推荐外部 `GET /``https://cms-jack.imharry.work/`,由外层 HTTPS 入口转发到本机 `80`代理 PC Vite dev:web`00-init-tools.sh nginx` 会禁用 `sites-enabled/default`,并尝试去掉 `sites-available/default` 里的 `default_server`,避免默认站点抢占 `:80`。若机上还有其它站点也写了 `default_server``nginx -t` 会报错,需在该站点配置中删除 `default_server`(保留 `listen 80;` 即可)。
**PC 构建**`08-build-pc.sh` 会在构建前注入 `VITE_API_URL``VITE_WS_URL``VITE_CHAT_URL``VITE_USER_URL` 等变量,并确保 `openIM.wasm``sql-wasm.wasm``wasm_exec.js` 存在于 `pc/public`。更新 `pc` 代码或 `.env.deploy-test` 后,需要重新执行 `./deploy-test/dt.sh pc-build`
**PC dev:web**`07-start-frontend.sh pc` 会在启动前注入 `VITE_API_URL``VITE_WS_URL``VITE_CHAT_URL``VITE_USER_URL` 等变量,并确保 `openIM.wasm``sql-wasm.wasm``wasm_exec.js` 存在于 `pc/public`。更新 `pc` 代码或 `.env.deploy-test` 后,需要重启 PC 前端:`./deploy-test/stop-frontend.sh pc && ./deploy-test/07-start-frontend.sh pc`
### Docker 基础设施