This commit is contained in:
vet
2026-04-20 21:44:25 +07:00
parent 0171f17439
commit a9f1547c69
6 changed files with 14 additions and 14 deletions

View File

@@ -323,7 +323,7 @@ _install_pc_nginx_proxy() {
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
local conf_src="${script_dir}/nginx/openim-pc-proxy.conf"
local conf_name="openim-pc-proxy.conf"
local proxy_domain="${PC_PROXY_DOMAIN:-cms-jack.imharry.work}"
local proxy_domain="${PC_PROXY_DOMAIN:-pc-jack.imharry.work}"
if [[ -f "$ENV_FILE" ]]; then
# shellcheck source=/dev/null

View File

@@ -109,8 +109,8 @@ TENCENT_SDK_SECRET_KEY=cceba44084aaa04f8c48a1858ffd5385875c3a5ec006d34278d9d3714
# 填写 HTTPS 根地址无末尾斜杠Nginx 会将 / 代理到 pc dev:web :5173并代理 API/WS。
# ./deploy-test/07-start-frontend.sh 启动 pc 时会 export VITE_*,覆盖 pc/.env无需改 pc 目录
# 若某路径与网关不一致可单独覆盖PC_VITE_API_URL / PC_VITE_WS_URL / PC_VITE_CHAT_URL / PC_VITE_USER_URL
PC_PROXY_DOMAIN=cms-jack.imharry.work
PC_BACKEND_ORIGIN=https://cms-jack.imharry.work
PC_PROXY_DOMAIN=pc-jack.imharry.work
PC_BACKEND_ORIGIN=https://pc-jack.imharry.work
EOF
success ".env.deploy-test 已写入: $ENV_FILE"

View File

@@ -308,7 +308,7 @@ TENCENT_SDK_SECRET_KEY=xxx
### Nginx 反代(域名 HTTPS 入口,供 PC / 浏览器访问后端)
在**测试服务器**上部署 Nginx本机 Nginx 仅监听 HTTP `:80`,统一反代 PC Vite dev:web server、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://pc-jack.imharry.work`HTTPS 由外层 LB/CDN/其它网关终止后转发到本机 `:80`
| 路径前缀 | 后端 |
|----------|------|
@@ -318,14 +318,14 @@ TENCENT_SDK_SECRET_KEY=xxx
| `/` | `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`**(无末尾 `/`)。
2. 域名 `pc-jack.imharry.work` 已解析到测试服务器公网 IP。
3. `.env.deploy-test` 中设置 **`PC_BACKEND_ORIGIN=https://pc-jack.imharry.work`**(无末尾 `/`)。
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/`**。
7. 浏览器打开 **`https://pc-jack.imharry.work/`**。
**域名访问**:本配置中 `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;` 即可)。
**域名访问**:本配置中 `openim-pc-proxy` 使用 `server_name pc-jack.imharry.work`,只监听本机 `80`;推荐外部 `GET /``https://pc-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 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`

View File

@@ -228,7 +228,7 @@ ALL_SVCS=(openim-server chat-rpc admin-rpc chat-api admin-api meetingmsg liveclo
# ── PC 反代入口环境归一化 ───────────────────────────────────────────────────────
normalize_pc_proxy_env() {
PC_PROXY_DOMAIN="${PC_PROXY_DOMAIN:-cms-jack.imharry.work}"
PC_PROXY_DOMAIN="${PC_PROXY_DOMAIN:-pc-jack.imharry.work}"
local default_origin="https://${PC_PROXY_DOMAIN}"
local origin="${PC_BACKEND_ORIGIN:-}"
origin="${origin%/}"

View File

@@ -10,7 +10,7 @@
# 返回 Access-Control-Allow-Origin: *。若在此再用 add_header 追加 $http_origin浏览器会收到
# 「*, http://IP:5173」两个值并报错。故本配置不在 Nginx 层添加 CORS预检 OPTIONS 也交给上游处理。
#
# 推荐外部访问入口https://cms-jack.imharry.work/
# 推荐外部访问入口https://pc-jack.imharry.work/
# 本 Nginx 仅监听 HTTP :80HTTPS 由外层 LB/CDN/网关终止后转发到本机 :80。
map $http_upgrade $connection_upgrade {
@@ -28,7 +28,7 @@ log_format openim_pc_gateway
server {
listen 80;
listen [::]:80;
server_name cms-jack.imharry.work;
server_name pc-jack.imharry.work;
client_max_body_size 100m;
add_header Cross-Origin-Opener-Policy "same-origin" always;

View File

@@ -212,7 +212,7 @@ cat <<'EOF'
userID = userID || await window.__deployTestReadLocalForage("IM_USERID");
token = token || await window.__deployTestReadLocalForage("IM_TOKEN");
const operationID = `deploy-test-${Date.now()}`;
const gatewayOrigin = window.location.origin || "https://cms-jack.imharry.work";
const gatewayOrigin = window.location.origin || "https://pc-jack.imharry.work";
const config = {
platformID: 5,
apiAddr: apiAddr || `${gatewayOrigin}/api/im`,
@@ -297,8 +297,8 @@ await window.__deployTestResetBrowserStorage()
await window.__deployTestManualInitDB()
清理后按这个顺序重测:
1. 关闭其它 https://cms-jack.imharry.work/ / http://54.116.29.247:5173 标签页
2. 打开 https://cms-jack.imharry.work/ 并刷新页面
1. 关闭其它 https://pc-jack.imharry.work/ / http://54.116.29.247:5173 标签页
2. 打开 https://pc-jack.imharry.work/ 并刷新页面
3. 重新粘贴本脚本输出的整段 JS刷新会清掉已安装的 probe
4. 再登录
5. 观察 counts 是否从 0 变 1以及 /var/log/nginx/openim-pc-proxy-access.log 是否出现 /msg_gateway