test
This commit is contained in:
19
README.md
19
README.md
@@ -103,6 +103,7 @@ 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
|
||||
@@ -307,26 +308,26 @@ TENCENT_SDK_SECRET_KEY=xxx
|
||||
|
||||
### Nginx 反代(域名 HTTPS 入口,供 PC / 浏览器访问后端)
|
||||
|
||||
在**测试服务器**上部署 Nginx,本机 Nginx 仅监听 HTTP `:80`,统一反代 PC Vite dev server、OpenIM API、chat-api 与 MsgGateway WebSocket。外部访问仍使用 `https://cms-jack.imharry.work`,HTTPS 由外层 LB/CDN/其它网关终止后转发到本机 `:80`。
|
||||
在**测试服务器**上部署 Nginx,本机 Nginx 仅监听 HTTP `:80`,直接访问 PC 构建产物 `/app/pc/dist`,并反代 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) |
|
||||
| `/openIM.wasm`、`/sql-wasm.wasm`、`/wasm_exec.js`、`/node_modules/@openim/wasm-client-sdk/lib/worker*.js` | `/var/www/openim-pc-sdk`(OpenIM WASM SDK 静态资源) |
|
||||
| `/` | `127.0.0.1:5173`(PC Vite dev server) |
|
||||
| `/` | `/app/pc/dist`(PC Web 静态构建产物) |
|
||||
|
||||
1. 服务器上已执行 `05-start.sh` 等,保证 `10001/10002/10008` 在监听。
|
||||
2. 域名 `cms-jack.imharry.work` 已解析到测试服务器公网 IP。
|
||||
3. 仓库根目录执行:`sudo ./deploy-test/00-init-tools.sh nginx`(会安装 `nginx`,并写入配置 `deploy-test/nginx/openim-pc-proxy.conf`;亦已包含在 `00-init-tools.sh` 无参的 **all** 流程末尾,需 root)。
|
||||
4. 测试服务器本机/安全组放行 **TCP 80**;外层 LB/CDN/网关对公网提供 HTTPS `443` 并转发到本机 `80`。
|
||||
5. `.env.deploy-test` 中设置 **`PC_BACKEND_ORIGIN=https://cms-jack.imharry.work`**(无末尾 `/`);再 `./deploy-test/07-start-frontend.sh pc` 启动 PC 时即注入 `VITE_*`。
|
||||
6. 浏览器打开 **`https://cms-jack.imharry.work/`**。
|
||||
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`。
|
||||
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` 后代理 PC Vite。`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` 后读取 `/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;` 即可)。
|
||||
|
||||
**PC WASM SDK 资源**:`00-init-tools.sh nginx` 会把 `pc/node_modules/@openim/wasm-client-sdk/lib/worker.js`、`worker-legacy.js` 以及 `openIM.wasm`、`sql-wasm.wasm`、`wasm_exec.js` 复制到 `/var/www/openim-pc-sdk`,并由 Nginx 直接返回这些文件。这样可以绕开 PC Vite dev server 里用于规避 MIME 报错的 `worker.js` placeholder,避免浏览器端 OpenIM SDK 卡在 worker 初始化阶段,导致不发起 `/api/im` 和 `/msg_gateway` 请求。更新 `pc` 依赖或 SDK 后,请重新执行 `sudo ./deploy-test/00-init-tools.sh nginx` 同步静态资源。
|
||||
**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`。
|
||||
|
||||
### Docker 基础设施
|
||||
|
||||
|
||||
Reference in New Issue
Block a user