Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c9e8e113d0 | ||
|
|
354495ec78 |
@@ -5,7 +5,6 @@
|
||||
# 不匹配 pc-client/src/components 等源码子目录,保证其可入库
|
||||
/components/
|
||||
.selftest/
|
||||
pc-client/dist-portal/
|
||||
data/
|
||||
**/agconnect-services.json
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
FROM node:20-alpine
|
||||
WORKDIR /app
|
||||
COPY server.js portal-sso.js admin.html ./
|
||||
COPY server.js admin.html ./
|
||||
ENV PORT=10010 DATA_FILE=/app/data/employees.json
|
||||
EXPOSE 10010
|
||||
CMD ["node", "server.js"]
|
||||
|
||||
@@ -1,142 +0,0 @@
|
||||
'use strict';
|
||||
const crypto = require('crypto');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const digest = s => crypto.createHash('sha256').update(s).digest('hex');
|
||||
const hex = s => typeof s === 'string' && /^[a-f0-9]{64}$/.test(s);
|
||||
|
||||
// Browser-bound portal tickets. OpenIM user IDs are permanent empids, not mutable staff numbers.
|
||||
module.exports = function createPortalBridge(deps, env = process.env) {
|
||||
const enabled = env.PORTAL_SSO_ENABLED === '1';
|
||||
if (!enabled) return { handle: async () => false };
|
||||
const portal = new URL(env.PORTAL_PUBLIC_URL);
|
||||
const internal = new URL(env.PORTAL_INTERNAL_URL);
|
||||
const secret = env.PORTAL_SSO_SECRET || '';
|
||||
if (!['http:', 'https:'].includes(internal.protocol) || portal.protocol !== 'https:' || secret.length < 32)
|
||||
throw new Error('Invalid portal configuration');
|
||||
const file = path.join(path.dirname(env.DATA_FILE), 'portal-sessions.json');
|
||||
let sessions = fs.existsSync(file) ? JSON.parse(fs.readFileSync(file, 'utf8')) : {};
|
||||
const cookieFlags = '; HttpOnly; Secure; SameSite=Lax; Path=/';
|
||||
const cookieName = '__Host-jxd_portal_sid';
|
||||
const save = () => {
|
||||
fs.mkdirSync(path.dirname(file), { recursive: true });
|
||||
fs.writeFileSync(file + '.tmp', JSON.stringify(sessions), { mode: 0o600 });
|
||||
fs.renameSync(file + '.tmp', file);
|
||||
};
|
||||
const cookies = req => Object.fromEntries(String(req.headers.cookie || '').split(';').map(p => {
|
||||
const n = p.indexOf('='); return [p.slice(0, n).trim(), p.slice(n + 1)];
|
||||
}));
|
||||
async function call(operation, payload) {
|
||||
const response = await fetch(new URL('/api/sso/apps/jinxunda/' + operation, internal), {
|
||||
method: 'POST', redirect: 'error', signal: AbortSignal.timeout(5000),
|
||||
headers: { Authorization: 'Bearer ' + secret, 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
if (!response.ok) throw new Error('Portal unavailable');
|
||||
return response.json();
|
||||
}
|
||||
function reply(res, status, value) {
|
||||
res.writeHead(status, { 'Content-Type': 'application/json; charset=utf-8',
|
||||
'Cache-Control': 'no-store', 'Referrer-Policy': 'no-referrer' });
|
||||
res.end(JSON.stringify(value));
|
||||
}
|
||||
function redirect(res, location, cookie) {
|
||||
res.writeHead(303, { Location: location, 'Set-Cookie': cookie,
|
||||
'Cache-Control': 'no-store', 'Referrer-Policy': 'no-referrer' }); res.end();
|
||||
}
|
||||
async function valid(row) {
|
||||
const r = await call('introspect', { session_handle: row.handle });
|
||||
return r.active && r.identity?.empid === row.empid && r.identity?.local_uid === row.localUid;
|
||||
}
|
||||
async function revoke(key) {
|
||||
const row = sessions[key];
|
||||
if (!row) return;
|
||||
row.revoked = true;
|
||||
save();
|
||||
// Persist revocation before kicking; failed kicks are retried by the sweep.
|
||||
const token = await deps.getAdminToken();
|
||||
const result = await deps.imApi('/auth/force_logout', { platformID: 5, userID: row.imUid }, token);
|
||||
if (result.errCode !== 0) throw new Error('IM revocation pending');
|
||||
delete sessions[key]; save();
|
||||
}
|
||||
let sweeping = false;
|
||||
const timer = setInterval(async () => {
|
||||
if (sweeping) return;
|
||||
sweeping = true;
|
||||
try {
|
||||
for (const [key, row] of Object.entries(sessions)) {
|
||||
let active = false;
|
||||
try { active = !row.revoked && await valid(row); } catch { /* fail closed */ }
|
||||
if (!active) { try { await revoke(key); } catch { /* retry next sweep */ } }
|
||||
}
|
||||
} finally { sweeping = false; }
|
||||
}, 10000);
|
||||
timer.unref();
|
||||
return {
|
||||
close: () => clearInterval(timer),
|
||||
async handle(req, res) {
|
||||
const url = new URL(req.url, 'http://localhost');
|
||||
const route = url.pathname;
|
||||
if (route === '/portal-sso') {
|
||||
if (req.method !== 'GET') { reply(res, 405, { message: 'Method not allowed' }); return true; }
|
||||
try {
|
||||
const ticket = url.searchParams.get('ticket');
|
||||
if (!ticket) {
|
||||
const verifier = crypto.randomBytes(32).toString('hex');
|
||||
const theme = url.searchParams.get('theme') === 'night' ? 'night' : 'day';
|
||||
const value = [verifier, Date.now(), theme].join('.');
|
||||
redirect(res, new URL('/api/sso/apps/jinxunda/authorize?challenge=' + digest(verifier), portal).href,
|
||||
'__Host-jxd_proof=' + value + cookieFlags + '; Max-Age=120');
|
||||
return true;
|
||||
}
|
||||
const [verifier, timestamp, theme] = (cookies(req)['__Host-jxd_proof'] || '').split('.');
|
||||
if (!hex(ticket) || !hex(verifier) || !Number.isFinite(Number(timestamp))
|
||||
|| Date.now() - Number(timestamp) > 120000 || Number(timestamp) > Date.now())
|
||||
throw new Error('Invalid browser proof');
|
||||
const result = await call('exchange', { ticket, verifier });
|
||||
const who = result.identity;
|
||||
if (!hex(result.session_handle) || !/^[a-f0-9-]{36}$/.test(who?.empid || '')
|
||||
|| !Number.isSafeInteger(who?.local_uid) || who.local_uid < 1)
|
||||
throw new Error('Invalid identity');
|
||||
// OpenIM rejects UUID hyphens. Preserve empid and derive its lossless 32-hex representation.
|
||||
const imUid = who.empid.replace(/-/g, '');
|
||||
if (!/^[a-f0-9]{32}$/.test(imUid)) throw new Error('Invalid permanent identity');
|
||||
if (!await deps.ensureImUser(imUid, who.display_name)) throw new Error('IM unavailable');
|
||||
const token = await deps.getImUserToken(imUid, 5);
|
||||
const sid = crypto.randomBytes(32).toString('hex');
|
||||
sessions[digest(sid)] = { handle: result.session_handle, empid: who.empid, imUid,
|
||||
localUid: who.local_uid, staffNo: who.username, name: who.display_name,
|
||||
token: token.token, theme: theme === 'night' ? 'night' : 'day' };
|
||||
save();
|
||||
redirect(res, '/#/chat', [cookieName + '=' + sid + cookieFlags + '; Max-Age=28800',
|
||||
'__Host-jxd_proof=' + cookieFlags + '; Max-Age=0']);
|
||||
} catch (error) {
|
||||
console.error('Portal SSO failed:', String(error.message).replace(/[a-f0-9]{32,}/gi, '[redacted]').slice(0, 180));
|
||||
reply(res, 401, { message: '统一登录未完成,请返回门户重新进入。', portal: portal.origin });
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (route === '/api/portal/session') {
|
||||
if (req.method !== 'GET') { reply(res, 405, {}); return true; }
|
||||
const sid = cookies(req)[cookieName];
|
||||
const key = hex(sid) ? digest(sid) : '';
|
||||
const row = sessions[key];
|
||||
try {
|
||||
if (!row || row.revoked || !await valid(row)) throw new Error('Invalid session');
|
||||
reply(res, 200, { userID: row.imUid, imToken: row.token, chatToken: row.token,
|
||||
displayName: row.name, staffNo: row.staffNo, theme: row.theme, portal: portal.origin });
|
||||
} catch {
|
||||
if (row) { try { await revoke(key); } catch { /* retry */ }
|
||||
}
|
||||
reply(res, 401, { message: '请从统一门户进入金讯达', portal: portal.origin });
|
||||
}
|
||||
return true;
|
||||
}
|
||||
// The existing app must not retain a parallel password/admin entry.
|
||||
if (route === '/api/login' || route === '/' || route === '/admin' || route.startsWith('/api/admin/')) {
|
||||
reply(res, 403, { message: '账号及登录统一由门户管理', portal: portal.origin }); return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
};
|
||||
};
|
||||
@@ -357,10 +357,8 @@ const routes = {
|
||||
},
|
||||
};
|
||||
|
||||
const portalBridge = require('./portal-sso')({ getAdminToken, imApi, ensureImUser, getImUserToken });
|
||||
const server = http.createServer(async (req, res) => {
|
||||
try {
|
||||
if (await portalBridge.handle(req, res)) return;
|
||||
const url = new URL(req.url, 'http://localhost');
|
||||
req.urlObj = url;
|
||||
if (req.method === 'OPTIONS') return send(res, 204, {});
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
'use strict';
|
||||
const test = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const http = require('http');
|
||||
const fs = require('fs');
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
const createBridge = require('./portal-sso');
|
||||
|
||||
test('portal proof, exchange, active session, revocation, and legacy login closure', async () => {
|
||||
const temp = fs.mkdtempSync(path.join(os.tmpdir(), 'jinniu-sso-test-'));
|
||||
let active = true, exchanges = 0, kicks = 0;
|
||||
const identity = { empid: 'fefafefa-1234-1234-1234-123456789abc', local_uid: 1, username: '019999', display_name: '管理员' };
|
||||
const portal = http.createServer(async (req, res) => {
|
||||
assert.equal(req.headers.authorization, 'Bearer ' + 's'.repeat(32));
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
if (req.url.endsWith('/exchange')) {
|
||||
exchanges++;
|
||||
res.end(JSON.stringify({ identity, session_handle: 'c'.repeat(64) }));
|
||||
} else res.end(JSON.stringify({active, identity}));
|
||||
});
|
||||
await new Promise(r => portal.listen(0,'127.0.0.1',r));
|
||||
const bridge = createBridge({
|
||||
ensureImUser: async (uid) => { assert.equal(uid, identity.empid.replace(/-/g,'')); return true; },
|
||||
getImUserToken: async (uid, pid) => { assert.equal(pid, 5); return {token:'private-im-token'}; },
|
||||
getAdminToken: async () => 'private-admin-token',
|
||||
imApi: async (route, body) => { assert.equal(body.userID, identity.empid.replace(/-/g,'')); kicks++; return {errCode:0}; },
|
||||
}, {PORTAL_SSO_ENABLED:'1', PORTAL_SSO_SECRET:'s'.repeat(32), PORTAL_PUBLIC_URL:'https://bg.example.test',
|
||||
PORTAL_INTERNAL_URL:'http://127.0.0.1:'+portal.address().port, DATA_FILE:path.join(temp,'employees.json')});
|
||||
const server = http.createServer(async (req,res) => { if (!await bridge.handle(req,res)) { res.writeHead(404);res.end(); } });
|
||||
await new Promise(r => server.listen(0,'127.0.0.1',r));
|
||||
const base = 'http://127.0.0.1:'+server.address().port;
|
||||
try {
|
||||
assert.equal((await fetch(base+'/api/login',{method:'POST'})).status,403);
|
||||
assert.equal((await fetch(base+'/api/admin/employees')).status,403);
|
||||
assert.equal((await fetch(base+'/api/portal/session')).status,401);
|
||||
assert.equal((await fetch(base+'/portal-sso?ticket='+'a'.repeat(64))).status,401);
|
||||
assert.equal(exchanges,0);
|
||||
const start = await fetch(base+'/portal-sso?theme=night',{redirect:'manual'});
|
||||
assert.equal(start.status,303);
|
||||
assert.match(start.headers.get('location'),/^https:\/\/bg\.example\.test\/api\/sso\/apps\/jinxunda\/authorize\?challenge=[a-f0-9]{64}$/);
|
||||
const proof = start.headers.get('set-cookie').split(';')[0];
|
||||
const finish = await fetch(base+'/portal-sso?ticket='+'a'.repeat(64),{redirect:'manual',headers:{cookie:proof}});
|
||||
assert.equal(finish.status,303);
|
||||
const cookie = finish.headers.getSetCookie()[0].split(';')[0];
|
||||
assert.match(finish.headers.getSetCookie()[0],/HttpOnly; Secure; SameSite=Lax/);
|
||||
let r = await fetch(base+'/api/portal/session',{headers:{cookie}});
|
||||
assert.equal(r.headers.get('cache-control'),'no-store');
|
||||
const profile=await r.json();
|
||||
assert.equal(profile.userID,identity.empid.replace(/-/g,''));
|
||||
assert.equal(profile.staffNo,'019999');
|
||||
assert.equal(profile.theme,'night');
|
||||
active=false;
|
||||
r = await fetch(base+'/api/portal/session',{headers:{cookie}});
|
||||
assert.equal(r.status,401);
|
||||
assert.equal(kicks,1);
|
||||
assert.deepEqual(JSON.parse(fs.readFileSync(path.join(temp,'portal-sessions.json'))),{});
|
||||
} finally {
|
||||
bridge.close();
|
||||
await new Promise(r=>server.close(r));
|
||||
await new Promise(r=>portal.close(r));
|
||||
assert.ok(path.resolve(temp).startsWith(path.resolve(os.tmpdir())+path.sep));
|
||||
fs.rmSync(temp,{recursive:true});
|
||||
}
|
||||
});
|
||||
+49
-7
@@ -1,11 +1,42 @@
|
||||
# 公网测试部署说明(jxd.jinniu.ink)
|
||||
|
||||
> **已过时,仅留档备查(2026-09-23)。** 当前 `154.37.220.158` 已由系统 Nginx 统一承接 80/443,`jxd-edge` 已移除。本页下方 edge 启停、证书和回滚步骤不能直接用于现网;先读 [最新交接](../../docs/项目交接-2026-09-23.md),核对现网配置与未合入 `main` 的部署变更,再制订新操作方案。
|
||||
|
||||
施工员本卡**不执行**本节命令、不 SSH 改测试机。由总工审核通过后再部署。
|
||||
|
||||
目标机:已解析到 `jxd.jinniu.ink` 的香港测试服务器。数据目录仍是仓库下的 `components/` 与 `data/`,回滚不删数据。
|
||||
|
||||
## 共享服务器铁律(HEL-551)
|
||||
|
||||
这台服务器不止跑金讯达一个项目(还要给 `solsum.cn` 等域名提供服务),所以:
|
||||
|
||||
- 公网 `80/443` 只能由**一套**统一入口持有——现在是系统/宝塔 Nginx,不是某个项目自己的容器。
|
||||
- 新增域名/项目,只在系统 Nginx 里新增一个站点配置文件,不要另起一个监听 80/443 的边缘容器。
|
||||
- 任何业务容器都不允许用 `network_mode: host` 或直接绑 `0.0.0.0:80` / `0.0.0.0:443` 抢占入口端口;容器只把业务端口绑到 `127.0.0.1`,由系统 Nginx 反代。
|
||||
- `jxd-edge`(HEL-279 时代的方案)已经因为这条铁律下线,定义保留在 `docker-compose.edge-fallback.yaml` 仅供应急回滚,不要在日常启动里叠加它。
|
||||
|
||||
## 统一入口:系统 Nginx 取代 jxd-edge
|
||||
|
||||
自 HEL-551 起,`jxd.jinniu.ink` 的 80/443 由服务器上的系统/宝塔 Nginx 直接持有并反代,不再用独占 host 网络的 `jxd-edge` 容器:
|
||||
|
||||
- 站点配置模板:`deploy/public/host-nginx/jxd.jinniu.ink.conf`(1:1 迁移了原 `nginx.conf` 里的全部路由:`/msg_gateway`、`/account/`、`/files/`、`/livekit/`、REST API catch-all、ACME challenge、HTTPS、超时与上传大小限制)。
|
||||
- `docker-compose.public.yaml` 里的 `edge` 服务已删除;金讯达各容器的内部端口本来就只绑 `127.0.0.1`,不受影响。
|
||||
- 切换脚本:`scripts/switch-to-host-nginx.sh`(备份 → 语法检查 → 停旧 edge → 启动/重载系统 Nginx → 健康检查,任一步失败自动回滚)。
|
||||
- 回滚脚本:`scripts/rollback-to-jxd-edge.sh`(禁用系统 Nginx 上的 jxd 站点文件,重新拉起 `jxd-edge`,配合 `deploy/public/docker-compose.edge-fallback.yaml`)。
|
||||
|
||||
切换步骤(总工在服务器上执行,按需通过环境变量覆盖 `HOST_NGINX_VHOST_DIR` / `HOST_NGINX_BIN` / `HOST_NGINX_INIT` 适配实际路径):
|
||||
|
||||
```bash
|
||||
cd /path/to/tongxunruanjian
|
||||
./scripts/switch-to-host-nginx.sh
|
||||
```
|
||||
|
||||
一键回滚(切换失败会自动触发,也可以随时手动执行):
|
||||
|
||||
```bash
|
||||
./scripts/rollback-to-jxd-edge.sh
|
||||
```
|
||||
|
||||
**APK 下载现状核实(HEL-552 复核修正)**:仓库里的旧 `nginx.conf` 曾缺少 APK 下载路由,但线上 `jxd-edge` 实际运行配置里**有** `/downloads/` 路由,并挂载了 `deploy/public/downloads`(HEL-279 验收后现场热修加入,仓库未同步)。已交付验收地址为 `https://jxd.jinniu.ink/downloads/jinxunda-android-test-1.0.9.apk`。现已把 `/downloads/` 路由补进系统 Nginx 站点模板(占位符 `__JXD_DOWNLOADS_DIR__`)、回滚用 `docker-compose.edge-fallback.yaml` 的挂载、以及本仓库 `nginx.conf` 本身,三处与线上一致,切换与回滚后该链接均不失效。
|
||||
|
||||
## 对外暴露与对内绑定
|
||||
|
||||
| 入口 | 协议 | 后端 | 说明 |
|
||||
@@ -21,11 +52,15 @@
|
||||
|
||||
## 证书
|
||||
|
||||
首次签发(历史步骤,测试机已经跑过一次,证书已经存在,仅在证书丢失/重建时才需要重跑):
|
||||
|
||||
1. 先把 `deploy/public/nginx.bootstrap.conf` 挂到 edge(只听 80)。
|
||||
2. `certbot certonly --webroot -w deploy/public/acme -d jxd.jinniu.ink`
|
||||
3. 确认 `/etc/letsencrypt/live/jxd.jinniu.ink/` 有 `fullchain.pem` 与 `privkey.pem`。
|
||||
4. 改回 `nginx.conf` 后重载 edge。
|
||||
|
||||
**HEL-551 后的续期**:系统 Nginx 站点配置(`deploy/public/host-nginx/jxd.jinniu.ink.conf`)里的 ACME challenge `root` 指向的还是同一个 `deploy/public/acme` 目录,`switch-to-host-nginx.sh` 会自动替换成绝对路径。只要 certbot 续期时仍用这个目录做 webroot,就不需要重新申请证书,也不用再依赖 `jxd-edge` 来响应 `.well-known/acme-challenge`。
|
||||
|
||||
私钥不得复制进 Git。
|
||||
|
||||
## 极光 Master Secret
|
||||
@@ -46,17 +81,24 @@ cp .env.example .env # 若还没有
|
||||
# 按 deploy/public/.env.public.example 写入 SERVER_IP、MINIO_EXTERNAL_ADDRESS、JPUSH_*(不含 Master Secret)
|
||||
source ./scripts/load-jpush-secret.sh
|
||||
./scripts/deploy-public.sh
|
||||
./scripts/switch-to-host-nginx.sh # HEL-551 起:让系统 Nginx 接管 80/443
|
||||
```
|
||||
|
||||
`SERVER_IP` 填本机公网 IP(LiveKit 媒体候选),不要写进手机/电脑客户端代码。
|
||||
|
||||
`deploy-public.sh` 本身只拉起金讯达容器(内部端口只绑 `127.0.0.1`),不再包含监听 80/443 的边缘容器;`switch-to-host-nginx.sh` 是让系统 Nginx 对外接管入口这一步,缺了它 `jxd.jinniu.ink` 在公网上访问不到。
|
||||
|
||||
## 回滚
|
||||
|
||||
```bash
|
||||
./scripts/rollback-public.sh
|
||||
```
|
||||
|
||||
效果:停掉 nginx edge,按原来的 `docker-compose.yaml` 拉起;`components/` 与 `data/account` 不动。
|
||||
- 只想让 jxd-edge 重新接管 80/443(系统 Nginx 切换出问题时的应急手段):
|
||||
```bash
|
||||
./scripts/rollback-to-jxd-edge.sh
|
||||
```
|
||||
- 想整体退回内网部署(不对外暴露):
|
||||
```bash
|
||||
./scripts/rollback-public.sh
|
||||
```
|
||||
效果:清理 jxd-edge(如果在跑),按原来的 `docker-compose.yaml` 拉起;`components/` 与 `data/account` 不动。系统 Nginx 上的 jxd 站点文件不受影响,需要的话手工禁用或用 `rollback-to-jxd-edge.sh` 里的第一步。
|
||||
|
||||
## 客户端地址(已写进代码默认值)
|
||||
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
# 应急回滚专用 overlay(HEL-551)——不要在日常启动里叠加这个文件。
|
||||
#
|
||||
# 这里保留的是 HEL-279 时代 jxd-edge 的原始定义:用 host 网络独占 80/443。
|
||||
# 只有在系统/宝塔 Nginx 切换失败、需要立刻恢复公网访问时才用它,配合
|
||||
# scripts/rollback-to-jxd-edge.sh 一起执行:
|
||||
#
|
||||
# docker compose \
|
||||
# -f docker-compose.yaml \
|
||||
# -f deploy/public/docker-compose.public.yaml \
|
||||
# -f deploy/public/docker-compose.edge-fallback.yaml \
|
||||
# up -d edge
|
||||
#
|
||||
# 恢复系统 Nginx 统一入口后,记得停掉并移除这个容器:
|
||||
# docker compose -f docker-compose.yaml -f deploy/public/docker-compose.public.yaml \
|
||||
# -f deploy/public/docker-compose.edge-fallback.yaml stop edge
|
||||
# docker compose -f docker-compose.yaml -f deploy/public/docker-compose.public.yaml \
|
||||
# -f deploy/public/docker-compose.edge-fallback.yaml rm -f edge
|
||||
#
|
||||
# 不得同时有 jxd-edge(host 网络)和系统 Nginx 一起监听 80/443——两者互斥。
|
||||
|
||||
services:
|
||||
edge:
|
||||
image: nginx:1.27-alpine
|
||||
container_name: jxd-edge
|
||||
restart: always
|
||||
network_mode: host
|
||||
volumes:
|
||||
- ./deploy/public/nginx.conf:/etc/nginx/nginx.conf:ro
|
||||
- ./deploy/public/acme:/var/www/acme:ro
|
||||
- ./deploy/public/downloads:/var/www/downloads:ro
|
||||
- /etc/letsencrypt:/etc/letsencrypt:ro
|
||||
depends_on:
|
||||
- openim-server
|
||||
- account-server
|
||||
- minio
|
||||
- livekit
|
||||
@@ -7,6 +7,14 @@
|
||||
# 原则:内部端口只绑 127.0.0.1;对外只开 80/443 + LiveKit 媒体 17881/tcp、17882/udp。
|
||||
# ports 使用 !override,避免与基础 compose 的 0.0.0.0 绑定叠加。
|
||||
# 回滚:去掉本 overlay,改回 docker compose -f docker-compose.yaml up -d,数据目录 components/ 与 data/ 不动。
|
||||
#
|
||||
# HEL-551:80/443 已交给系统/宝塔 Nginx 统一持有,本 overlay 不再包含独占
|
||||
# host 网络的 jxd-edge 容器(这是共享服务器上和其他域名冲突的根因)。
|
||||
# 上面几个服务的内部端口本来就只绑 127.0.0.1,系统 Nginx 直接反代这些端口即可,
|
||||
# 见 deploy/public/host-nginx/jxd.jinniu.ink.conf。
|
||||
# 应急回滚(系统 Nginx 切换失败时)才用得到旧的 edge 容器定义,见
|
||||
# deploy/public/docker-compose.edge-fallback.yaml 与 scripts/rollback-to-jxd-edge.sh,
|
||||
# 不要把 edge-fallback 叠进日常启动命令。
|
||||
|
||||
services:
|
||||
openim-server:
|
||||
@@ -42,18 +50,3 @@ services:
|
||||
account-server:
|
||||
ports: !override
|
||||
- "127.0.0.1:${ACCOUNT_PORT:-10010}:10010"
|
||||
|
||||
edge:
|
||||
image: nginx:1.27-alpine
|
||||
container_name: jxd-edge
|
||||
restart: always
|
||||
network_mode: host
|
||||
volumes:
|
||||
- ./deploy/public/nginx.conf:/etc/nginx/nginx.conf:ro
|
||||
- ./deploy/public/acme:/var/www/acme:ro
|
||||
- /etc/letsencrypt:/etc/letsencrypt:ro
|
||||
depends_on:
|
||||
- openim-server
|
||||
- account-server
|
||||
- minio
|
||||
- livekit
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
# jxd.jinniu.ink 站点配置 —— 给系统/宝塔 Nginx 用(HEL-551)。
|
||||
#
|
||||
# 用途:把这个文件放进系统 Nginx 的站点目录(宝塔一般是
|
||||
# /www/server/panel/vhost/nginx/,原生 Nginx 一般是 /etc/nginx/conf.d/),
|
||||
# 让系统 Nginx 作为 80/443 的唯一持有者,替换掉原来独占 host 网络的
|
||||
# jxd-edge 容器。不要整份替换系统 Nginx 的 nginx.conf,这里只是新增一个
|
||||
# 站点文件,和 solsum.cn 等其他站点的配置文件平级共存。
|
||||
#
|
||||
# 使用前必须替换的占位符:
|
||||
# __JXD_ACME_WEBROOT__ -> 本机 tongxunruanjian 仓库的绝对路径 + /deploy/public/acme
|
||||
# (例如 /opt/tongxunruanjian/deploy/public/acme)。
|
||||
# 这必须是 certbot 当初签发 jxd.jinniu.ink 证书时用的同一个
|
||||
# webroot 目录,这样证书续期不用重新申请。
|
||||
# __JXD_DOWNLOADS_DIR__ -> 本机 tongxunruanjian 仓库的绝对路径 + /deploy/public/downloads
|
||||
# (例如 /opt/tongxunruanjian/deploy/public/downloads)。
|
||||
# 安卓测试安装包目录,对应原 jxd-edge 的 /downloads/ 路由,
|
||||
# 已交付的验收链接 /downloads/jinxunda-android-test-1.0.9.apk 依赖它。
|
||||
# scripts/switch-to-host-nginx.sh 会自动完成这两个替换,见该脚本与
|
||||
# ../README.md「切换到系统 Nginx」一节;手工部署时也可以自己 sed 替换。
|
||||
#
|
||||
# 依赖的后端端口(均只监听 127.0.0.1,由 docker-compose.public.yaml 保证):
|
||||
# OpenIM 消息网关 127.0.0.1:10001
|
||||
# OpenIM API 127.0.0.1:10002
|
||||
# 账号服务 127.0.0.1:10010
|
||||
# MinIO(对象存储) 127.0.0.1:10005
|
||||
# LiveKit 信令 127.0.0.1:17880
|
||||
# 如果 .env 里改过 *_PORT,要同步改这里的端口号。
|
||||
#
|
||||
# 说明:/msg_gateway 与 /livekit/ 是专用的 WebSocket 升级端点,这里直接把
|
||||
# Connection 头写死成 "upgrade",不依赖全局 map $http_upgrade $connection_upgrade
|
||||
# 指令 —— 这样这个站点文件可以独立存在,不需要改系统 Nginx 主配置的 http{} 块。
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
server_name jxd.jinniu.ink;
|
||||
|
||||
# ACME HTTP-01 挑战,续期证书用。
|
||||
location /.well-known/acme-challenge/ {
|
||||
root __JXD_ACME_WEBROOT__;
|
||||
}
|
||||
|
||||
location / {
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
# http2 指令写法需要 nginx >= 1.25.1(目标服务器宝塔 nginx 为 1.28.0)。
|
||||
# 不要写回 `listen 443 ssl http2`,1.25.1+ 上会报弃用告警。
|
||||
listen 443 ssl;
|
||||
listen [::]:443 ssl;
|
||||
http2 on;
|
||||
server_name jxd.jinniu.ink;
|
||||
|
||||
ssl_certificate /etc/letsencrypt/live/jxd.jinniu.ink/fullchain.pem;
|
||||
ssl_certificate_key /etc/letsencrypt/live/jxd.jinniu.ink/privkey.pem;
|
||||
ssl_session_timeout 1d;
|
||||
ssl_session_cache shared:SSL:10m;
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
ssl_prefer_server_ciphers off;
|
||||
|
||||
client_max_body_size 100m;
|
||||
|
||||
# 宝塔主配置的 http{} 里有全局 proxy_cache(见 /www/server/nginx/conf/proxy.conf 的
|
||||
# proxy_cache cache_one),API/WebSocket 代理绝不能吃缓存——显式关掉,
|
||||
# 保持与原 jxd-edge(无任何缓存)行为一致。
|
||||
proxy_cache off;
|
||||
|
||||
# OpenIM 消息长连接(WebSocket)
|
||||
location /msg_gateway {
|
||||
proxy_pass http://127.0.0.1:10001/;
|
||||
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_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_read_timeout 3600s;
|
||||
proxy_send_timeout 3600s;
|
||||
}
|
||||
|
||||
# 公司账号服务(登录、管理页、rtc_token)
|
||||
location /account/ {
|
||||
proxy_pass http://127.0.0.1:10010/;
|
||||
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_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
|
||||
# MinIO 对象(MINIO_EXTERNAL_ADDRESS=https://jxd.jinniu.ink/files)
|
||||
location /files/ {
|
||||
proxy_pass http://127.0.0.1:10005/;
|
||||
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_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_request_buffering off;
|
||||
}
|
||||
|
||||
# LiveKit 信令(客户端 wss://jxd.jinniu.ink/livekit/ ...)
|
||||
location /livekit/ {
|
||||
proxy_pass http://127.0.0.1:17880/;
|
||||
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_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_read_timeout 3600s;
|
||||
proxy_send_timeout 3600s;
|
||||
}
|
||||
|
||||
# 安卓测试安装包下载(1:1 迁移自线上 jxd-edge 的 /downloads/ 路由,HEL-552 复核补齐)。
|
||||
# 已交付验收地址:https://jxd.jinniu.ink/downloads/jinxunda-android-test-1.0.9.apk
|
||||
location /downloads/ {
|
||||
alias __JXD_DOWNLOADS_DIR__/;
|
||||
types {
|
||||
application/vnd.android.package-archive apk;
|
||||
}
|
||||
default_type application/octet-stream;
|
||||
add_header Content-Disposition "attachment";
|
||||
limit_except GET HEAD {
|
||||
deny all;
|
||||
}
|
||||
}
|
||||
|
||||
# OpenIM REST API(catch-all,须放最后)
|
||||
location / {
|
||||
proxy_pass http://127.0.0.1:10002;
|
||||
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_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
}
|
||||
@@ -108,6 +108,19 @@ http {
|
||||
proxy_send_timeout 3600s;
|
||||
}
|
||||
|
||||
# 安卓测试安装包(只读下载目录)
|
||||
location /downloads/ {
|
||||
alias /var/www/downloads/;
|
||||
types {
|
||||
application/vnd.android.package-archive apk;
|
||||
}
|
||||
default_type application/octet-stream;
|
||||
add_header Content-Disposition "attachment";
|
||||
limit_except GET HEAD {
|
||||
deny all;
|
||||
}
|
||||
}
|
||||
|
||||
# OpenIM REST API(catch-all,须放最后)
|
||||
location / {
|
||||
proxy_pass http://openim_api;
|
||||
|
||||
+6
-6
@@ -1,10 +1,10 @@
|
||||
# 金讯达项目手册
|
||||
# 畅联项目手册
|
||||
|
||||
这是项目的交接首页。新接手的人先按下面顺序阅读,不要只凭旧文档或聊天记录判断项目状态。
|
||||
|
||||
1. 先读 [2026-09-23 项目交接](项目交接-2026-09-23.md):最新部署状态、风险和接下来的计划。
|
||||
2. 再读 [项目需求](项目需求.md):弄清楚项目要做什么、不能碰什么。
|
||||
3. [最新进度](最新进度.md)和[任务清单](任务清单.md)是精简索引;旧验收记录仅供追溯。
|
||||
1. 先读 [项目需求](项目需求.md):弄清楚项目要做什么、不能碰什么。
|
||||
2. 再读 [最新进度](最新进度.md):确认代码已经做到哪里、哪些结论已经被验证。
|
||||
3. 最后读 [任务清单](任务清单.md):从“正在做”和“还没安排”里选择下一件事。
|
||||
|
||||
## 仓库里有什么
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
- `pc-client/`:电脑端,使用 Electron,Windows 是当前优先支持的平台。
|
||||
- `account-service/`:公司账号服务,负责工号密码登录、管理员导入和管理名单。
|
||||
- `docker-compose.yaml`、`config/`、`scripts/`:OpenIM、语音服务和内网环境的配置及维护脚本。
|
||||
- `deploy/public/`:早期公网部署资料。旧 edge 操作不适用于当前系统 Nginx 统一入口,不要直接执行。
|
||||
- `deploy/public/`:香港测试机 `jxd.jinniu.ink` 的公网反代、证书和回滚说明(由总工部署)。
|
||||
- `docs/`:本手册和以前留下的验收、回归、使用说明。
|
||||
|
||||
## 更新规矩
|
||||
@@ -24,4 +24,4 @@
|
||||
- 任务状态变化时,更新 `任务清单.md` 的三栏,并写明依据。
|
||||
- 旧文档不能删除;如果它和当前事实不一致,在旧文档开头加“已过时,仅留档备查”提示,再在本目录写新版。
|
||||
|
||||
手册只记录已经确认的事实。拿不准的内容要写成“待确认”,不要当成已完成。
|
||||
手册只记录已经确认的事实。拿不准的内容要写成“待确认”,不要当成已完成。
|
||||
@@ -1,24 +0,0 @@
|
||||
# 金讯达统一门户网页试运行
|
||||
|
||||
网页地址 https://jxd.jinniu.ink,唯一身份入口 https://bg.jinniu.ink。
|
||||
|
||||
account-service 设置 PORTAL_SSO_ENABLED=1、PORTAL_PUBLIC_URL、PORTAL_INTERNAL_URL 和独立不少于32字符的 PORTAL_SSO_SECRET。该密钥必须与门户 JINXUNDA_SSO_SECRET 一致。现有 OpenIM 管理服务密钥仍通过私有环境文件提供。
|
||||
|
||||
`/portal-sso` 使用浏览器 verifier 绑定的短期一次性票据。身份使用永久 empid,OpenIM UID 为去掉 UUID 连字符的32位十六进制表示。不能用工号改名重新创建聊天身份。
|
||||
`/api/portal/session` 同源且禁止缓存;每次验证门户会话。后台每10秒撤销失效用户平台5会话,失败会重试。会话文件仅服务端可读,原口令登录和管理API在门户模式禁用。
|
||||
|
||||
构建 pc-client 网页版本时配置:
|
||||
|
||||
```
|
||||
VITE_PORTAL_MODE=1
|
||||
VITE_PORTAL_URL=https://bg.jinniu.ink
|
||||
VITE_API_URL=https://jxd.jinniu.ink
|
||||
VITE_WS_URL=wss://jxd.jinniu.ink/msg_gateway
|
||||
VITE_ACCOUNT_URL=https://jxd.jinniu.ink/account
|
||||
VITE_LIVEKIT_URL=wss://jxd.jinniu.ink/livekit/
|
||||
```
|
||||
|
||||
执行 `npx vite build --config vite.portal.config.ts`,输出 dist-portal。Nginx 将根路径/资源指向该目录,SSO及会话接口代理账号服务;原OpenIM、对象存储、LiveKit路由保留。
|
||||
|
||||
验证:`node --test test-portal-sso.js test-admin-page.js`(在account-service目录);真实HTTPS兑换OpenIM凭证、浏览器进入聊天、返回门户、退出撤销已验收。
|
||||
仅保留一个正式管理员,因此双人消息、音视频、附件尚未完成真实员工验收。原生Windows/Android客户端仍为历史登录机制,需要另行适配门户登录;不能视为本次网页交付已覆盖。
|
||||
+27
-11
@@ -1,17 +1,33 @@
|
||||
# 任务清单
|
||||
|
||||
更新时间:2026-09-23。旧协调卡 HEL-4 及相关子卡收口后,以 [项目交接](项目交接-2026-09-23.md)为新任务依据。旧卡关闭不等于整个项目已验收。
|
||||
更新时间:2026-08-31。任务状态以当前仓库和项目约束为准;没有证据的事项不写成“已完成”。
|
||||
|
||||
## 已交付
|
||||
## 正在做
|
||||
|
||||
- Flutter 安卓端、Electron Windows 端、账号服务、OpenIM/LiveKit 集成与历史跨端回归记录。
|
||||
- 安卓名称/图标/包名调整,极光和华为构建配置接入,测试包生成。
|
||||
- 香港测试机系统 Nginx 统一入口;金讯达网页并入统一门户。网页单人登录、退出及入口可访问性已有记录。
|
||||
无。安卓自适应图标已按 66dp 安全区重做,版本 `1.0.9+10`,等待审核。
|
||||
HEL-294 员工管理页接口路径与英文报错热修:代码和本地自测已完成,等待部署到香港测试环境后由管理员在公网 `/account/` 页面验收。
|
||||
|
||||
## 下一步新开独立任务
|
||||
## 已做完
|
||||
|
||||
1. 审核并同步现网 Nginx 配置与仓库代码,补齐金讯达证书自动续期及回滚演练(原 HEL-554;到期风险优先)。
|
||||
2. 两名真实员工跨安卓、Windows、网页验收消息、附件与一对一语音通话;华为真机验收离线推送。
|
||||
3. 确定账号导入和原生端门户登录策略,准备安卓正式签名及安全保管。
|
||||
4. 根据资质进展另行接其他安卓厂商推送与 iOS。
|
||||
5. 如仍需 `solsum.cn` 根域名 HTTPS,另行处理证书域名不匹配(原 HEL-553;不属于金讯达当前域名接入阻塞)。
|
||||
- 建立手机端 Flutter 工程和 Windows 优先的 Electron 电脑端工程。
|
||||
- 接入公司工号加密码登录,以及管理员导入、管理员工账号的账号服务。
|
||||
- 完成聊天、通讯录、同事申请、语音消息、文件/图片消息和一对一语音通话的相关代码接入。
|
||||
- 完成一轮手机与电脑的跨端回归记录;其中已通过的项目见旧档 `phase4-regression-2026-08-16.md`。
|
||||
- 将 LiveKit 的信令/媒体端口统一为 `17880`、`17881`、`17882`,并提供可重复执行的修复脚本。
|
||||
- 建立本目录四份交接手册,并为三份过时旧说明加上明确的留档提示。
|
||||
- 手机端应用标识统一为 `cn.solsum.jinxunda`。
|
||||
- 安卓极光 SDK 初始化、通知权限、alias 回传、点击处理,以及 OpenIM 离线推送所需的服务端配置入口(Master Secret 从服务器文件注入)。
|
||||
- 公网反向代理 / HTTPS / WSS / 防火墙与回滚说明(配置进仓库;香港测试环境已由总工部署)。
|
||||
- 公网 overlay 用 `!override` 覆盖内部端口绑定;部署脚本校验 `SERVER_IP` 非空。
|
||||
- 构建机本地放入华为 `agconnect-services.json`(不入库);AGConnect 插件映射/版本已按 AGP 9 补齐,Gradle 能识别包名 `cn.solsum.jinxunda`。
|
||||
- 升级 `livekit_client` 至 `2.10.0`,在 Flutter 3.47 / Dart 3.13 下打出整包安卓 release APK。
|
||||
- 安卓桌面名称改为「金讯达」,按正式参考图生成各密度与自适应图标;随后按真机裁切问题把前景缩进 66dp 安全区,版本提升到 `1.0.9+10` 并重新出包。
|
||||
- HEL-294:管理页按部署前缀请求账号接口,并给 401/404/500/空响应/非 JSON 提供中文兜底(代码已合入分支,公网部署前现网仍会报英文错)。
|
||||
|
||||
## 还没安排
|
||||
|
||||
- 用真机验证华为厂商通道到达,以及一对一语音通话。
|
||||
- 组织真实手机和 Windows 电脑的回归:重点确认文件传输、一对一语音通话和杀进程后的离线通知。
|
||||
- 明确手机正式签名的负责人和安全保管方式;不能把签名密钥提交进仓库。
|
||||
- 获得负责人同意后,再导入真实员工名单并验证账号管理流程。
|
||||
- 不接入小米、OPPO、vivo、荣耀、魅族、FCM 或苹果推送(本阶段明确不做)。
|
||||
|
||||
+40
-6
@@ -1,9 +1,43 @@
|
||||
# 最新进度
|
||||
|
||||
更新时间:2026-09-23。详细事实、证据边界和下一步见 [项目交接](项目交接-2026-09-23.md)。
|
||||
更新时间:2026-08-31。以下内容依据当前仓库代码整理。
|
||||
|
||||
- 最新测试服务器:`154.37.220.158`;系统 Nginx 统一承接 80/443,金讯达网页 `https://jxd.jinniu.ink` 已由负责人整合到统一门户 `https://bg.jinniu.ink`。
|
||||
- 当日只读检查表明网页与账号健康检查可访问,安卓测试包可下载,OpenIM、账号服务、LiveKit 等服务运行;尚不能据此判定双人通讯和推送验收通过。
|
||||
- 安卓代码版本 `1.0.9+10`,包名 `cn.solsum.jinxunda`,名称与图标已经调整;Windows 文档版本 `v1.0.2`。安卓极光和华为配置已有接入,真机到达率仍待验证。
|
||||
- 门户网页已验证单人登录与退出;两个真实员工之间的消息、附件、语音通话仍待验收。Android/Windows 原生端还未适配门户登录;iOS、其他安卓厂商推送、正式签名尚未完成。
|
||||
- 现网统一入口的变更尚未同步进仓库 `main`;旧 `jxd-edge` 部署指令不适用于现网。证书自动续期仍待补齐。
|
||||
## 现在做到哪里
|
||||
|
||||
项目已经具备可继续测试的手机端、Windows 电脑端、账号服务,香港测试环境已由总工部署。本轮在 `1.0.8+9` 图标交付基线上,修正了安卓自适应图标安全区并重新出包:
|
||||
|
||||
- 手机端在 `mobile/`,使用 OpenIM Flutter SDK `3.8.3+hotfix.12`,版本 `1.0.9+10`。
|
||||
- 安卓/苹果应用标识为 `cn.solsum.jinxunda`。
|
||||
- 安卓桌面、最近任务和系统应用信息的显示名称为「金讯达」(`values` / `values-zh` / `values-zh-rCN` / `values-en` 均为此名)。登录页与聊天页文案未改。
|
||||
- 安卓自适应图标不再把带圆角的整张 PNG 顶格作为前景:红色背景铺满 108dp,前景把完整标识放进中心 66dp 安全区;legacy 方/圆图标仍是完整标识。真机 1.0.8 安装器裁切已按此修正。
|
||||
- 手机端已接入极光官方 Flutter 插件(AppKey 在客户端配置),登录后把 OpenIM userID 设为极光 alias。
|
||||
- 华为 AGConnect 插件在放入本地 `agconnect-services.json` 后启用(agcp `1.9.5.301`,适配 AGP 9);该文件含密钥,仓库继续忽略,不入库。
|
||||
- 手机默认服务地址为 `jxd.jinniu.ink` 的 HTTPS/WSS;内网可用 `--dart-define=SERVER_HOST=... --dart-define=USE_TLS=false` 覆盖。
|
||||
- 公网部署 overlay、Nginx、证书步骤、Master Secret 注入脚本和回滚脚本在 `deploy/public/` 与 `scripts/deploy-public.sh`;由总工部署,施工员不改测试机。
|
||||
- overlay 的内部端口用 Compose `!override` 覆盖基础 `0.0.0.0` 绑定,只留 `127.0.0.1`;LiveKit `17881/tcp`、`17882/udp` 仍对公网开放。部署脚本会拒绝空 `SERVER_IP`。
|
||||
- 电脑端在 `pc-client/`,使用 Electron,显示版本 `v1.0.2`。
|
||||
- 员工用工号和密码通过 `account-service/` 登录;管理员导入和管理账号的页面、接口已在仓库中。
|
||||
- HEL-294:管理页接口改为适配 `/account/` 部署前缀;非 JSON/空响应改为中文提示,不再把浏览器英文异常直接展示。热修代码已提交,尚未部署到公网。
|
||||
- 手机和电脑端已接入聊天、通讯录、同事申请、语音消息、文件/图片消息和一对一语音通话相关代码。
|
||||
- 语音服务 LiveKit 的信令和媒体端口已统一为 `17880`、`17881`、`17882`;仓库提供 `scripts/fix-livekit-ports.sh` 用于服务器已部署环境的端口修复。
|
||||
|
||||
## 已有验证记录
|
||||
|
||||
- `docs/phase4-regression-2026-08-16.md` 记录过手机与电脑之间的文字、同事申请、图片、语音消息等跨端回归结果。
|
||||
- 该记录中的文件传输和一对一语音通话,曾因模拟器环境无法闭环,仍需要用真实设备再次确认。
|
||||
- 旧记录使用的是更早的提交、安装包版本和端口状态;因此已保留为档案并在开头标明过时,不能当作当前验收结论。
|
||||
- 放入与 `cn.solsum.jinxunda` 匹配的真实华为配置后,Gradle `:app:processDebugAGCPlugin` 与 `:app:processReleaseAGCPlugin` 通过;debug/release/profile 均识别该配置文件。未因配置缺失或包名不一致失败。
|
||||
- `flutter pub get` 已写入 `jpush_flutter 3.5.6` / `jpush_flutter_android 1.0.2` 到 `mobile/pubspec.lock`。
|
||||
- `flutter analyze` 仅有 2 条既有 OpenIM `group` 弃用 info;`flutter test`(`config_test` 与登录页 widget_test)通过。
|
||||
- 语音组件已升级到 `livekit_client 2.10.0`(配套直接依赖 `uuid 4.5.3`),Flutter 3.47 / Dart 3.13 下可编译。
|
||||
- 整包 `flutter build apk` 已打出 release 安装包 `app-release.apk`,包名 `cn.solsum.jinxunda`,版本 `1.0.9+10`。
|
||||
|
||||
## 当前停在哪
|
||||
|
||||
华为配置可被 Gradle 识别,整包安卓安装包已能在当前工具链打出。真机华为通道到达率、真机一对一语音通话仍待真机验证。本轮未改测试机、未回退公网端口与部署安全修复。
|
||||
|
||||
## 已知风险和待验证事实
|
||||
|
||||
- 真机上的文件传输、一对一语音通话、杀进程后的离线推送(尤其华为通道)仍需实际设备验证。
|
||||
- 当前 release 包仍用调试签名;正式签名需后续单独准备,密钥不得入库。
|
||||
- 电脑端使用较旧的 Electron;公网接入后仍需评估 HTTPS、登录限流和跨域策略。
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
# 金讯达项目交接(2026-09-23)
|
||||
|
||||
本页是旧协调卡 HEL-4 归档后的项目入口。它记录截至本日能核实的状态与下一步,不代表整个项目已经验收完成。后续请以新的、范围明确的任务卡推进,并在完成时更新本页。不得把密钥、员工资料或私钥写入仓库。
|
||||
|
||||
## 当前部署和入口
|
||||
|
||||
- 当前香港**测试**服务器公网地址:`154.37.220.158`;`jxd.jinniu.ink` 指向这台服务器。正式上线前仍需独立验收。
|
||||
- 集团统一门户为 `https://bg.jinniu.ink`。负责人已自行把金讯达网页端整合进统一门户;网页地址为 `https://jxd.jinniu.ink`,网页身份入口以门户为准,详情见 [网页试运行说明](portal-web-trial.md)。
|
||||
- 2026-09-23 只读核对:系统 Nginx 占用 80/443,配置检查通过;金讯达网页、账号健康检查均返回 HTTP 200,现有安卓测试包下载支持 HTTP 206 分段下载。OpenIM、账号服务、LiveKit、MinIO 及其依赖容器当时在运行。**这只证明服务和入口当时可用,不等于聊天、通话或推送已完成用户验收。**
|
||||
- 现网由系统 Nginx 统一承接 80/443;原 `jxd-edge` 容器已移除。`deploy/public/README.md` 的 edge 启停步骤是旧方案,禁止直接照其操作现网。
|
||||
|
||||
## 代码与已经交付的能力
|
||||
|
||||
- 代码包含 Flutter 手机端、Electron/网页端、公司账号服务,以及 OpenIM、LiveKit 等部署配置。安卓包名 `cn.solsum.jinxunda`,版本 `1.0.9+10`;安卓名称为“金讯达”,已按系统自适应图标安全区调整图标。Windows 客户端当前文档版本为 `v1.0.2`。
|
||||
- 手机和电脑端已有工号密码登录、通讯录、聊天、图片/文件/语音消息及一对一语音通话相关代码;历史跨端测试记录见 [回归记录](phase4-regression-2026-08-16.md),不能拿历史记录代替当前版本的真机验收。
|
||||
- 安卓已接入极光 SDK 与华为 AGConnect 构建配置;华为配置文件及极光 Master Secret 均为私有材料,不入库。其他安卓厂商通道与苹果推送尚未完成。
|
||||
- 网页端已接入统一门户单点登录。现有网页试运行记录覆盖登录、会话兑换与退出;当时仅有一个正式管理员,尚无两个真实员工之间的消息、音视频、附件完整验收。原生 Android/Windows 客户端仍使用旧登录机制,尚未统一为门户登录。
|
||||
- 本仓库 `main` 已含网页门户整合代码;服务器 Nginx 统一入口相关改动曾交付于另一个分支,**截至本日尚未合入 `main`**。后续部署前要先审查并同步该分支及现网配置,不能直接用 `main` 的旧 edge 脚本覆盖现网。
|
||||
|
||||
## 尚未完成、按优先级推进
|
||||
|
||||
1. **P0:统一部署基线与证书。** 审查并合入系统 Nginx 统一入口相关代码,核对现网配置、备份和回滚路径;补齐 `jxd.jinniu.ink` 证书自动续期。现有证书到期日记录为 2026-11-28,应在 2026-11-14 前完成自动续期及演练。原 HEL-554 尚未执行,不得因旧卡归档误认为已完成。
|
||||
2. **P1:真实员工验收。** 准备两个获授权的测试员工账号,在安卓、Windows、网页之间验证登录、双向消息、附件、语音消息与一对一语音通话;华为真机验证前台、后台和被系统结束后的通知到达与点击。记录设备、版本、时间和失败现象;不得以健康检查代替这些测试。
|
||||
3. **P1:账号及发布安全。** 负责人确认员工名单导入与权限边界;安卓正式发布前改用受保护的正式签名,不能把签名密钥入库。评估网页门户身份与原生客户端旧登录并存的期限,以及原生端是否改用门户登录。
|
||||
4. **P2:其余平台。** 其他安卓厂商通道待各厂商资质完成后再接;iOS 的 Apple 开发者账号、推送凭据、构建和真机验收另立任务,不视为本阶段已完成。
|
||||
5. **P2:`solsum.cn` 证书问题。** 原 HEL-553 记录其根域名证书只覆盖 `www`,与金讯达当前 `jxd.jinniu.ink` 接入不是同一个阻塞;如仍需根域名 HTTPS,由该域名负责人另开独立任务处理。
|
||||
|
||||
## 旧任务卡收口说明
|
||||
|
||||
HEL-4 是跨阶段协调卡,不是“项目全部完工”的证明。归档时,已交付的子卡记为完成;未执行的 HEL-553、HEL-554 仅关闭旧卡、把风险迁入上方计划。以后请从此文档开新卡,不继续在旧长线程里追加施工。实际状态以当时运行环境和最新代码为准。
|
||||
+4
-5
@@ -2,7 +2,7 @@
|
||||
|
||||
## 项目是什么
|
||||
|
||||
“金讯达”是集团内部使用的通讯 App,也就是给员工聊天、找同事和语音通话的工具。项目以开源 OpenIM 为基础改造;员工使用的安卓应用已采用经负责人确认的“金讯达”名称和图标。OpenIM 的第三方标识、许可和署名仍须按其许可保留。
|
||||
“畅联”是集团内部使用的通讯 App,也就是给员工聊天、找同事和语音通话的工具。项目以开源 OpenIM 为基础改造,保留 OpenIM 原有标识,不换品牌、不另起一套产品标识。
|
||||
|
||||
## 要解决什么
|
||||
|
||||
@@ -20,13 +20,12 @@
|
||||
|
||||
- 手机端:Android 和 iPhone 工程都在仓库中;当前手机端版本号为 `1.0.9+10`。应用标识 `cn.solsum.jinxunda`。安卓桌面/最近任务/系统应用信息显示名称为「金讯达」。
|
||||
- 电脑端:Windows 优先;当前电脑端显示版本为 `v1.0.2`。
|
||||
- 网页端:已由负责人整合进统一门户,入口 `https://bg.jinniu.ink`,业务页面 `https://jxd.jinniu.ink`;网页身份以门户为准。原生 Android/Windows 尚未同步门户登录。
|
||||
- 服务端:以 Docker Compose(把一组服务一起启动的工具)编排 OpenIM、账号服务和语音服务。当前香港测试机为 `154.37.220.158`,域名 `jxd.jinniu.ink`(HTTPS/WSS);系统 Nginx 承接 80/443。仓库旧 edge 部署资料不得直接用于现网。
|
||||
- 服务端:以 Docker Compose(把一组服务一起启动的工具)编排 OpenIM、账号服务和语音服务。公网测试域名为 `jxd.jinniu.ink`(HTTPS/WSS),部署配置在 `deploy/public/`,实际部署由总工执行。
|
||||
|
||||
## 当前边界
|
||||
|
||||
- 只做集团内部通讯,不改造成公开社交产品。
|
||||
- 尊重 OpenIM 第三方许可与署名;用户可见应用品牌为“金讯达”,不据此改写 OpenIM 上游代码中的许可信息。
|
||||
- 保留 OpenIM 的现有标识,禁止替换品牌。
|
||||
- 公网第一阶段:安卓极光 + 华为厂商通道(`agconnect-services.json` 只放构建机、不入库,见 `mobile/android/app/README-agconnect.md`);不接小米/OPPO/vivo/荣耀/魅族/FCM/苹果推送。
|
||||
- 不把员工名单、密码、管理员口令、极光 Master Secret、华为 Secret、私钥或服务器私密配置写入仓库和文档。
|
||||
- 本仓库的日常任务如无明确授权,不做发布、部署或改动生产环境。
|
||||
- 本仓库的日常任务如无明确授权,不做发布、部署或改动生产环境。
|
||||
@@ -25,7 +25,6 @@ import { OverlayVisibleHandle } from "../../hooks/useOverlayVisible";
|
||||
import About from "./About";
|
||||
import styles from "./left-nav-bar.module.scss";
|
||||
import PersonalSettings from "./PersonalSettings";
|
||||
import { portalMode } from '@/portal';
|
||||
|
||||
const AppIcon = () => (
|
||||
<div className="flex h-9 w-9 items-center justify-center rounded-lg bg-[var(--primary)]">
|
||||
@@ -282,7 +281,7 @@ const LeftNavBar = memo(() => {
|
||||
))}
|
||||
</div>
|
||||
|
||||
{!portalMode && <Popover
|
||||
<Popover
|
||||
content={ProfileContent}
|
||||
trigger="click"
|
||||
placement="rightBottom"
|
||||
@@ -298,7 +297,7 @@ const LeftNavBar = memo(() => {
|
||||
src={selfInfo.faceURL}
|
||||
text={selfInfo.nickname}
|
||||
/>
|
||||
</Popover>}
|
||||
</Popover>
|
||||
<PersonalSettings ref={personalSettingsRef} />
|
||||
<About ref={aboutRef} />
|
||||
</div>
|
||||
|
||||
@@ -9,7 +9,6 @@ import { useUserStore } from "@/store";
|
||||
import GlobalModals from "./GlobalModals";
|
||||
import LeftNavBar from "./LeftNavBar";
|
||||
import { useGlobalEvent } from "./useGlobalEvents";
|
||||
import { portalMode, portalHome } from '@/portal';
|
||||
|
||||
export const MainContentLayout = () => {
|
||||
useGlobalEvent();
|
||||
@@ -36,8 +35,7 @@ export const MainContentLayout = () => {
|
||||
|
||||
return (
|
||||
<Spin className="!max-h-none" spinning={showLockLoading} tip={loadingTip}>
|
||||
{portalMode && <header className="portal-header jn-portal-bar"><strong>金讯达</strong><span>金牛集团 · 内部通讯</span><a className="jn-portal-return" title="返回统一门户" aria-label="返回统一门户" href={portalHome + '?theme=' + document.documentElement.dataset.theme}><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><path d="m3 10 9-7 9 7v10a1 1 0 0 1-1 1h-5v-7H9v7H4a1 1 0 0 1-1-1Z"/></svg><span>统一门户</span></a></header>}
|
||||
<Layout className="relative h-full flex-row" style={portalMode ? {height: 'calc(100% - 56px)'} : undefined}>
|
||||
<Layout className="relative h-full flex-row">
|
||||
<LeftNavBar />
|
||||
<Outlet />
|
||||
{/* 悬浮窗口控制条:无边框窗口的拖动区 + 最小化/关闭 */}
|
||||
|
||||
+1
-20
@@ -7,9 +7,6 @@ import ReactDOM from "react-dom/client";
|
||||
|
||||
import App from "./App";
|
||||
import { isSaveLog } from "./config";
|
||||
import { initializePortal, portalHome, portalMode } from './portal';
|
||||
import './portal.scss';
|
||||
import './portal-return.css';
|
||||
|
||||
if (window.electronAPI && isSaveLog) {
|
||||
const sdkLogger = log.scope("openim-sdk-core");
|
||||
@@ -19,22 +16,6 @@ if (window.electronAPI && isSaveLog) {
|
||||
console.error = rendererLogger.error.bind(rendererLogger);
|
||||
}
|
||||
|
||||
initializePortal().then(ready => {
|
||||
const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement);
|
||||
root.render(ready ? <App /> : <main style={{padding: 48}}><h1>金讯达</h1>
|
||||
<p>请从统一门户登录并进入金讯达。</p><a href={portalHome}>返回统一门户</a></main>);
|
||||
if (ready && portalMode) {
|
||||
let checking = false;
|
||||
setInterval(async () => {
|
||||
if (checking) return;
|
||||
checking = true;
|
||||
try {
|
||||
const response = await fetch('/api/portal/session', { cache: 'no-store' });
|
||||
if (!response.ok) window.location.replace(portalHome);
|
||||
} catch { window.location.replace(portalHome); }
|
||||
finally { checking = false; }
|
||||
}, 10000);
|
||||
}
|
||||
});
|
||||
ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(<App />);
|
||||
|
||||
postMessage({ payload: "removeLoading" }, "*");
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { Layout } from "antd";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { portalMode } from "@/portal";
|
||||
|
||||
export const EmptyChat = () => {
|
||||
const { t } = useTranslation();
|
||||
@@ -16,7 +15,7 @@ export const EmptyChat = () => {
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
<div className="mt-4 text-base font-medium">{portalMode ? '金讯达' : t("placeholder.title")}</div>
|
||||
<div className="mt-4 text-base font-medium">{t("placeholder.title")}</div>
|
||||
<div className="mt-1 text-xs text-[var(--sub-text)]">
|
||||
{t("placeholder.subTitle")}
|
||||
</div>
|
||||
|
||||
@@ -8,13 +8,10 @@ import { feedbackToast } from "@/utils/common";
|
||||
|
||||
import styles from "./index.module.scss";
|
||||
import LoginForm from "./LoginForm";
|
||||
import { portalMode, portalHome } from '@/portal';
|
||||
|
||||
export const Login = () => {
|
||||
const [_, copyToClipboard] = useCopyToClipboard();
|
||||
|
||||
if (portalMode) return <main style={{padding: 48}}><p>登录已失效,请返回门户重新进入。</p><a href={portalHome}>返回统一门户</a></main>;
|
||||
|
||||
const handleCopy = () => {
|
||||
copyToClipboard(`${`${APP_NAME} ${APP_VERSION}`}/${SDK_VERSION}`);
|
||||
feedbackToast({ msg: t("toast.copySuccess") });
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
/* Shared portal navigation: same geometry in all four applications. */
|
||||
.jn-portal-bar { position: relative; min-height: 56px; box-sizing: border-box; padding-right: 160px !important; }
|
||||
a.jn-portal-return, a.jn-portal-return:link, a.jn-portal-return:visited {
|
||||
position: absolute; top: 10px; right: 16px; z-index: 2;
|
||||
display: inline-flex; align-items: center; justify-content: center; gap: 8px;
|
||||
box-sizing: border-box; height: 36px; min-width: 124px; padding: 0 12px;
|
||||
border: 1px solid #e7c7c3; border-radius: 10px; margin: 0;
|
||||
background: #fff7f5; color: #a92e24; box-shadow: 0 1px 2px rgba(64,25,20,.04);
|
||||
font: 600 13px/1.2 -apple-system,BlinkMacSystemFont,"Segoe UI","Microsoft YaHei",sans-serif;
|
||||
text-decoration: none; white-space: nowrap; cursor: pointer;
|
||||
}
|
||||
a.jn-portal-return svg { width: 18px; height: 18px; flex: none; }
|
||||
a.jn-portal-return span { color: inherit !important; font: inherit; }
|
||||
a.jn-portal-return:hover { background: #faeae6; color: #92251d; border-color: #d99c94; text-decoration: none; }
|
||||
a.jn-portal-return:focus-visible { outline: 3px solid #b83a2d; outline-offset: 3px; }
|
||||
[data-theme="night"] a.jn-portal-return { background: #382927; border-color: #70504b; color: #ffb4a8; }
|
||||
[data-theme="night"] a.jn-portal-return:hover { background: #4a312c; color: #ffd0c7; }
|
||||
@media (max-width: 600px) {
|
||||
.jn-portal-bar { padding-right: 124px !important; }
|
||||
a.jn-portal-return, a.jn-portal-return:link, a.jn-portal-return:visited { right: 12px; min-width: 102px; gap: 6px; padding: 0 9px; }
|
||||
}
|
||||
@media print { a.jn-portal-return { display: none !important; } }
|
||||
@@ -1,20 +0,0 @@
|
||||
html[data-portal='true'] {
|
||||
--primary: #b32635;
|
||||
--primary-active: #f6e8e9;
|
||||
--top-search-bar: #b32635;
|
||||
--chat-bubble-sender: #f4dfe1;
|
||||
.portal-header { height: 56px; display: flex; align-items: center; gap: 20px; padding: 0 24px; border-bottom: 1px solid var(--gap-text); background: #fff; }
|
||||
.portal-header strong { color: var(--primary); font-size: 20px; }
|
||||
.portal-header span { color: var(--sub-text); }
|
||||
@media (max-width: 600px) { .portal-header > span { display: none; } }
|
||||
.ant-spin-nested-loading, .ant-spin-container { height: 100%; }
|
||||
&[data-theme='night'] {
|
||||
color-scheme: dark;
|
||||
--primary: #e2737d; --primary-active: #35272a; --base-black: #e9e5df;
|
||||
--sub-text: #a8a29a; --gap-text: #3b3634; --search-bg: #292626;
|
||||
--chat-bg: #201e1d; --chat-bubble: #312d2b; --chat-bubble-sender: #4b3034;
|
||||
background: #201e1d;
|
||||
.portal-header, .bg-white, .ant-layout { background: #252221 !important; }
|
||||
input, textarea, .ant-input, .ant-modal-content, .ant-popover-inner { background: #292626; color: #e9e5df; }
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
import { setIMProfile, clearIMProfile } from './utils/storage';
|
||||
export const portalMode = import.meta.env.VITE_PORTAL_MODE === '1';
|
||||
export const portalHome = import.meta.env.VITE_PORTAL_URL || '';
|
||||
|
||||
export async function initializePortal(): Promise<boolean> {
|
||||
if (!portalMode) return true;
|
||||
try {
|
||||
const response = await fetch('/api/portal/session', { cache: 'no-store', credentials: 'same-origin' });
|
||||
if (!response.ok) throw new Error('Session expired');
|
||||
const profile = await response.json();
|
||||
await setIMProfile(profile);
|
||||
document.documentElement.dataset.theme = profile.theme === 'night' ? 'night' : 'day';
|
||||
document.documentElement.dataset.portal = 'true';
|
||||
document.title = '金讯达 · 金牛集团';
|
||||
return true;
|
||||
} catch {
|
||||
clearIMProfile();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,9 @@ export const setIMProfile = ({
|
||||
imToken: string;
|
||||
userID: string;
|
||||
}) => {
|
||||
return Promise.all([setTMToken(imToken), setChatToken(chatToken), setTMUserID(userID)]);
|
||||
setTMToken(imToken);
|
||||
setChatToken(chatToken);
|
||||
setTMUserID(userID);
|
||||
};
|
||||
|
||||
export const setLocale = (locale: string) => localStorage.setItem("IM_LOCALE", locale);
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
import { defineConfig } from 'vite';
|
||||
import react from '@vitejs/plugin-react';
|
||||
import path from 'node:path';
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
resolve: { alias: { '@': path.resolve(__dirname, 'src') } },
|
||||
build: { outDir: 'dist-portal', sourcemap: false },
|
||||
});
|
||||
@@ -43,3 +43,4 @@ docker compose \
|
||||
|
||||
echo "已提交 compose 启动。检查: docker compose -f docker-compose.yaml -f deploy/public/docker-compose.public.yaml ps"
|
||||
echo "证书未就绪时先用 nginx.bootstrap.conf 申请证书,见 deploy/public/README.md"
|
||||
echo "HEL-551 起 80/443 由系统 Nginx 持有,还需执行: ./scripts/switch-to-host-nginx.sh"
|
||||
|
||||
@@ -1,11 +1,19 @@
|
||||
#!/usr/bin/env bash
|
||||
# 公网 overlay 回滚到内网 compose:停掉 edge,按原 docker-compose.yaml 拉起。
|
||||
# 公网 overlay 回滚到内网 compose:按原 docker-compose.yaml 拉起。
|
||||
# 不删除 components/ 与 data/,不改现网数据文件。
|
||||
#
|
||||
# HEL-551 后 80/443 由系统 Nginx 持有,日常 docker-compose.public.yaml 里已经
|
||||
# 没有 edge 服务;这里额外叠上 docker-compose.edge-fallback.yaml,是为了兼容
|
||||
# “当前处于 rollback-to-jxd-edge.sh 应急状态、jxd-edge 容器还在跑”这种情况,
|
||||
# 确保它也能被一起清理。系统 Nginx 上的 jxd 站点文件不受本脚本影响,需要的话
|
||||
# 用 scripts/rollback-to-jxd-edge.sh 或手工禁用。
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
docker compose -f docker-compose.yaml -f deploy/public/docker-compose.public.yaml stop edge || true
|
||||
docker compose -f docker-compose.yaml -f deploy/public/docker-compose.public.yaml rm -f edge || true
|
||||
docker compose -f docker-compose.yaml -f deploy/public/docker-compose.public.yaml \
|
||||
-f deploy/public/docker-compose.edge-fallback.yaml stop edge 2>/dev/null || true
|
||||
docker compose -f docker-compose.yaml -f deploy/public/docker-compose.public.yaml \
|
||||
-f deploy/public/docker-compose.edge-fallback.yaml rm -f edge 2>/dev/null || true
|
||||
|
||||
docker compose -f docker-compose.yaml up -d
|
||||
|
||||
|
||||
Executable
+31
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env bash
|
||||
# HEL-551:紧急回滚——系统 Nginx 让出 jxd.jinniu.ink 站点,jxd-edge 用 host
|
||||
# 网络重新独占 80/443。由总工在服务器上执行;施工员本卡不跑本脚本。
|
||||
#
|
||||
# 用法: ./scripts/rollback-to-jxd-edge.sh
|
||||
# 只禁用 jxd 这一个站点文件(改后缀 .disabled,不删除,不影响系统 Nginx
|
||||
# 上的其他站点,例如 solsum.cn),然后重载系统 Nginx。
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
HOST_NGINX_VHOST_DIR="${HOST_NGINX_VHOST_DIR:-/www/server/panel/vhost/nginx}"
|
||||
HOST_NGINX_INIT="${HOST_NGINX_INIT:-/etc/init.d/nginx}"
|
||||
SITE_CONF_NAME="jxd.jinniu.ink.conf"
|
||||
|
||||
echo "== 1/2 禁用系统 Nginx 上的 jxd.jinniu.ink 站点 =="
|
||||
if [ -f "${HOST_NGINX_VHOST_DIR}/${SITE_CONF_NAME}" ]; then
|
||||
mv "${HOST_NGINX_VHOST_DIR}/${SITE_CONF_NAME}" "${HOST_NGINX_VHOST_DIR}/${SITE_CONF_NAME}.disabled"
|
||||
"$HOST_NGINX_INIT" reload 2>/dev/null || systemctl reload nginx 2>/dev/null || true
|
||||
else
|
||||
echo "未找到 ${HOST_NGINX_VHOST_DIR}/${SITE_CONF_NAME},跳过禁用步骤"
|
||||
fi
|
||||
|
||||
echo "== 2/2 重新拉起 jxd-edge(host 网络,独占 80/443) =="
|
||||
docker compose \
|
||||
-f docker-compose.yaml \
|
||||
-f deploy/public/docker-compose.public.yaml \
|
||||
-f deploy/public/docker-compose.edge-fallback.yaml \
|
||||
up -d edge
|
||||
|
||||
echo "回滚完成,jxd-edge 已重新接管 80/443。检查: docker compose ps"
|
||||
echo "数据目录 components/ 与 data/ 未动。"
|
||||
Executable
+104
@@ -0,0 +1,104 @@
|
||||
#!/usr/bin/env bash
|
||||
# HEL-551:把公网 80/443 从 jxd-edge(host 网络容器)切换到系统/宝塔 Nginx。
|
||||
# 由总工在服务器上执行;施工员本卡不跑本脚本,也不 SSH 改现网。
|
||||
#
|
||||
# 用法: ./scripts/switch-to-host-nginx.sh
|
||||
# 失败时自动回滚到 jxd-edge;也可以随时手动跑 ./scripts/rollback-to-jxd-edge.sh。
|
||||
#
|
||||
# 执行前可以按实际环境覆盖这几个变量,默认按宝塔面板的常见路径:
|
||||
# HOST_NGINX_VHOST_DIR 站点配置目录(宝塔: /www/server/panel/vhost/nginx)
|
||||
# HOST_NGINX_BIN nginx 可执行文件,用来做 -t 语法检查
|
||||
# HOST_NGINX_INIT initscript,用来启动/重载(宝塔一般装了 /etc/init.d/nginx)
|
||||
# HOST_NGINX_PIDFILE 系统 Nginx 的 pid 文件(宝塔: /www/server/nginx/logs/nginx.pid)
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
REPO_DIR="$(pwd)"
|
||||
|
||||
SITE_CONF_SRC="deploy/public/host-nginx/jxd.jinniu.ink.conf"
|
||||
SITE_CONF_NAME="jxd.jinniu.ink.conf"
|
||||
ACME_WEBROOT="${REPO_DIR}/deploy/public/acme"
|
||||
DOWNLOADS_DIR="${REPO_DIR}/deploy/public/downloads"
|
||||
|
||||
HOST_NGINX_VHOST_DIR="${HOST_NGINX_VHOST_DIR:-/www/server/panel/vhost/nginx}"
|
||||
HOST_NGINX_BIN="${HOST_NGINX_BIN:-/www/server/nginx/sbin/nginx}"
|
||||
HOST_NGINX_INIT="${HOST_NGINX_INIT:-/etc/init.d/nginx}"
|
||||
HOST_NGINX_PIDFILE="${HOST_NGINX_PIDFILE:-/www/server/nginx/logs/nginx.pid}"
|
||||
|
||||
# 判断"系统 Nginx 本尊"是否在跑,只认 pidfile 里的进程。
|
||||
# 不能用裸 pgrep -x nginx:宿主机上还有别的 nginx 容器(如 solsum 首页容器的
|
||||
# nginx -g daemon off),它们会让 pgrep 误报"系统 Nginx 已在跑",导致对已停止的
|
||||
# 系统 Nginx 执行 reload(必然失败),80/443 陷入无人监听。
|
||||
nginx_running() {
|
||||
[ -f "$HOST_NGINX_PIDFILE" ] && kill -0 "$(cat "$HOST_NGINX_PIDFILE" 2>/dev/null)" 2>/dev/null
|
||||
}
|
||||
|
||||
BACKUP_DIR="/root/jxd-nginx-switch-backup-$(date +%Y%m%d%H%M%S)"
|
||||
|
||||
rollback() {
|
||||
echo "!! 切换失败,回滚到 jxd-edge" >&2
|
||||
./scripts/rollback-to-jxd-edge.sh || true
|
||||
exit 1
|
||||
}
|
||||
|
||||
echo "== 1/5 备份系统 Nginx 站点目录、金讯达 compose、证书续期引用 =="
|
||||
mkdir -p "$BACKUP_DIR"
|
||||
if [ -d "$HOST_NGINX_VHOST_DIR" ]; then
|
||||
cp -a "$HOST_NGINX_VHOST_DIR" "$BACKUP_DIR/vhost-nginx"
|
||||
fi
|
||||
cp -a docker-compose.yaml deploy/public/docker-compose.public.yaml "$BACKUP_DIR/"
|
||||
if [ -f "/etc/letsencrypt/renewal/jxd.jinniu.ink.conf" ]; then
|
||||
mkdir -p "$BACKUP_DIR/letsencrypt-renewal"
|
||||
cp -a /etc/letsencrypt/renewal/jxd.jinniu.ink.conf "$BACKUP_DIR/letsencrypt-renewal/"
|
||||
fi
|
||||
echo "备份完成: $BACKUP_DIR"
|
||||
|
||||
echo "== 2/5 生成站点配置(替换 ACME webroot / downloads 占位符)=="
|
||||
mkdir -p "$ACME_WEBROOT"
|
||||
TMP_CONF="$(mktemp)"
|
||||
sed -e "s#__JXD_ACME_WEBROOT__#${ACME_WEBROOT}#g" \
|
||||
-e "s#__JXD_DOWNLOADS_DIR__#${DOWNLOADS_DIR}#g" \
|
||||
"$SITE_CONF_SRC" > "$TMP_CONF"
|
||||
|
||||
if [ ! -d "$HOST_NGINX_VHOST_DIR" ]; then
|
||||
echo "站点目录 $HOST_NGINX_VHOST_DIR 不存在,请先用 HOST_NGINX_VHOST_DIR= 指定正确路径" >&2
|
||||
rm -f "$TMP_CONF"
|
||||
exit 1
|
||||
fi
|
||||
cp "$TMP_CONF" "${HOST_NGINX_VHOST_DIR}/${SITE_CONF_NAME}"
|
||||
rm -f "$TMP_CONF"
|
||||
|
||||
echo "== 3/5 校验系统 Nginx 配置语法(先检查,不合格立即退出,不动服务)=="
|
||||
if ! "$HOST_NGINX_BIN" -t; then
|
||||
echo "系统 Nginx 配置检查失败,移除新站点文件,不触碰任何服务" >&2
|
||||
rm -f "${HOST_NGINX_VHOST_DIR}/${SITE_CONF_NAME}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "== 4/5 停 jxd-edge,启动/重载系统 Nginx =="
|
||||
docker compose -f docker-compose.yaml -f deploy/public/docker-compose.public.yaml \
|
||||
-f deploy/public/docker-compose.edge-fallback.yaml stop edge 2>/dev/null || true
|
||||
docker compose -f docker-compose.yaml -f deploy/public/docker-compose.public.yaml \
|
||||
-f deploy/public/docker-compose.edge-fallback.yaml rm -f edge 2>/dev/null || true
|
||||
|
||||
if nginx_running; then
|
||||
"$HOST_NGINX_INIT" reload || systemctl reload nginx || rollback
|
||||
else
|
||||
"$HOST_NGINX_INIT" start || systemctl start nginx || rollback
|
||||
fi
|
||||
|
||||
sleep 1
|
||||
if ! nginx_running; then
|
||||
rollback
|
||||
fi
|
||||
|
||||
echo "== 5/5 健康检查 =="
|
||||
sleep 1
|
||||
CODE="$(curl -sk -o /dev/null -w '%{http_code}' --max-time 5 https://jxd.jinniu.ink/ || echo 000)"
|
||||
if [ "$CODE" = "000" ]; then
|
||||
echo "https://jxd.jinniu.ink/ 无响应(code=$CODE)" >&2
|
||||
rollback
|
||||
fi
|
||||
|
||||
echo "切换完成。系统 Nginx 已独占 80/443,jxd-edge 已下线。"
|
||||
echo "备份目录: $BACKUP_DIR"
|
||||
echo "如需回滚: ./scripts/rollback-to-jxd-edge.sh"
|
||||
Reference in New Issue
Block a user