gongxiangp2/docs/NETWORK_TOPOLOGY.md
chenpei 7326e273e1 fix: harden media upload and release safety
Protect upload cleanup and atomic completion paths, add durable media worker leases and brand asset validation, and introduce verified migration/bootstrap/deployment gates.
2026-08-12 18:04:08 +08:00

169 lines
6.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 网络拓扑文档
> 更新时间:2026-07-09
> 本文只记录当前正式口径,不再把历史旁路和备用域名混进默认方案。
## 1. 正式入口
- 主站:`sc.jiansun.vip -> 218.93.9.38`
- 资源 / S3:`s3.jiansun.vip -> 218.93.9.38`
- 内网生产机:`192.168.58.20`
- 当前公网入口机:新穿透服务器 `218.93.9.38`
- 历史入口:`103.118.245.6` 不再作为当前默认排障入口。
- 已停用入口:`180.97.215.57` 不再作为正式资源入口或缓存入口使用。
- 历史入口:`180.97.221.140`、`156.239.227.105` 不再作为当前默认排障入口。
## 2. 当前正式链路
### 2.1 主站
```text
公网用户
-> https://sc.jiansun.vip
-> 218.93.9.38
-> nginx
-> 127.0.0.1:2321
-> FRP 专用入口
-> 192.168.58.20:4320
```
说明:
- 主站公网入口只认 `sc.jiansun.vip`。
- 首页自动切到 `192.168.58.20:4320` 的逻辑已经下线。
- `180.97.221.140:2320` 不再作为正式入口链路的一部分。
- `sc.jiansun.vip` 的 nginx 必须放开大文件上传:`client_max_body_size 2048m`,并设置较长 `proxy_read_timeout` / `proxy_send_timeout`。2026-05-07 曾因该配置缺失导致 `/api/materials/upload/chunk` 50MB 分片被 nginx 直接返回 `413`,表现为素材上传一直卡住。
- 当前前端分片策略是内网 20MB / 2 并发,公网 10MB / 1 并发;公网不要再默认使用 50MB 大分片,否则会放大 nginx + FRP 链路抖动下的 `499` / `502` 和上传 100% 后长时间等待问题。
### 2.2 资源 / S3
```text
公网用户
-> https://s3.jiansun.vip
-> 218.93.9.38
-> nginx
-> 127.0.0.1:2323
-> FRP
-> 192.168.58.20:9000
```
说明:
- `180.97.215.57` 已停用,不再作为 `s3.jiansun.vip` 的正式链路。
- 当前资源域名和主站域名都收敛到 `218.93.9.38` 入口机。
- `s3.jiansun.vip` 是否命中缓存不再作为当前正式验证标准,先以域名可达、FRP 可达、MinIO 回源可达为准。
- `s3.yydd.ai` 不再作为正式资源入口。
## 3. 展示资源口径
### 3.1 正式展示前缀
- 正式展示图统一落到:`/gongxiangpan/public-display/`
当前应走这个前缀的对象包括:
- 白底图预览
- 任务-详情主图 / SKU 图 / 详情图预览
- 素材库通用预览图、展示图、模特图等展示型图片
- AI 生图平台最终对外展示图
### 3.2 不再默认承担展示资源的路径
- `/gongxiangpan/uploads/`
说明:
- `uploads` 保留为混合区和历史兼容区。
- 首期不做历史对象全量迁移。
- 新生成展示图直接写 `public-display`,不再指望 `uploads` 承担正式展示路径。
### 3.3 不纳入 `public-display` 展示图/缓存规则的大对象
视频预览、预览片段和封面仍然会写入 S3 并通过对应的媒体 URL 提供播放;本节只说明它们不使用图片展示资源的 `public-display` 前缀和缓存规则。
- 视频源文件(canonical 源仍在生产机 uploads/NAS)
- 视频预览大文件(对象仍在 S3,但不走 `public-display` 前缀)
- 压缩包
- 其它下载型源文件
## 4. 已完成的入口收口
### 4.1 `218.93.9.38`
- 主站 `nginx upstream` 使用 `127.0.0.1:2321`
- 资源 / S3 `nginx upstream` 使用 `127.0.0.1:2323`
- FRPS 服务:`frps-jiansun-entry`
- FRPS 端口:`7002`
- 入口配置:`/etc/nginx/conf.d/cutover-legacy.conf`
- FRPS 配置:`/opt/frp/frps-jiansun-entry.toml`
- FRPS 日志:`/var/log/frps-jiansun-entry.log`
### 4.2 `180.97.221.140`
- 旧 `127.0.0.1:2320 backup` 已移除
- `frps` 已不再开放 `2320` / `2330`
- 防火墙已移除 `2320/tcp` 和 `2330/tcp`
- 不再作为当前默认公网入口。
### 4.3 `192.168.58.20`
- `/etc/frp/frpc.toml` 中旧 `2320 -> 4320`、`2330 -> 9000` 映射已移除
- `frpc-sc-entry` 仍保留正式主站 `2321 -> 4320`
- `frpc-s3-jiansun-entry` 保留正式资源入口 `2323 -> 9000`
- `frpc-s3-entry` 面向 `180.97.215.57` 的旧资源入口不再作为正式链路使用
- `frpc-sc-health-check` 必须检查 `218.93.9.38:7002`
- 2026-05-07 曾因 `/root/frp/frpc-sc-health-check.sh` 仍检查旧入口 `156.239.227.105:7002`,误判正式 `frpc-sc-entry` 异常并约每 70 秒重启一次,导致公网上传从 `413` 修复后继续出现 `502`、`499`、`408` 和卡住。
- 2026-07-09 当前正式入口已切到 `218.93.9.38`,不要再沿用旧入口判断健康状态。
### 4.4 `180.97.215.57`
- 已停用,不再作为 `s3.jiansun.vip` 的正式入口。
- 相关 `180G` nginx 磁盘缓存方案只作为历史记录保留,不再作为当前上线或排障门禁。
## 5. 当前验证标准
### 5.1 主站
- `https://sc.jiansun.vip` 应能通过 `218.93.9.38 -> nginx -> 127.0.0.1:2321 -> FRP -> 192.168.58.20:4320` 返回页面。
- 如果公网直接超时,优先检查 `218.93.9.38` 的公网可达性、`nginx`、`frps-jiansun-entry` 和生产机 `frpc-sc-entry`。
- 上传排障要同时看 `218.93.9.38:/var/log/nginx/error.log`,如果出现 `client intended to send too large body`,说明入口机 `sc.jiansun.vip` 的上传 body 限制配置丢失或未生效。
- 如果不再出现 `413`,但 `/api/materials/upload/chunk` 仍出现 `502`、`499`、`408`,继续检查生产机 `frpc-sc-health-check.service` 是否又用旧入口误判并重启 `frpc-sc-entry.service`。
### 5.2 资源 / S3
- `https://s3.jiansun.vip` 应能通过 `218.93.9.38 -> nginx -> 127.0.0.1:2323 -> FRP -> 192.168.58.20:9000` 回源。
- 不再使用 `180.97.215.57` 或 `127.0.0.1:29000` 作为正式资源验证链路。
### 5.3 历史缓存验证
- 过去关于 `X-Cache-Status: MISS/HIT/BYPASS` 的验证结果属于 `180.97.215.57` 缓存方案历史记录。
- 当前排障不要再把 `180.97.215.57` 缓存层作为默认检查项。
## 6. 当前对外说明口径
- 主站统一写:`https://sc.jiansun.vip`
- 资源统一写:`https://s3.jiansun.vip`
- 展示资源统一写:`https://s3.jiansun.vip/gongxiangpan/public-display/...`
不要再把下面这些写成正式入口:
- `s3.yydd.ai`
- `http://180.97.221.140:2320`
- `http://180.97.221.140:2330`
- `http://156.239.227.105:7002`
- `http://192.168.58.20:4320`
- `http://180.97.215.57`
## 7. 建议验证命令
```bash
# 主站
curl -I https://sc.jiansun.vip
# 展示资源
curl -I https://s3.jiansun.vip/gongxiangpan/public-display/network-check/20260325-cache-test.png
# 大文件访问
curl -I https://s3.jiansun.vip/gongxiangpan/由壹点AI/video-preview-720p-9b1c86b6-0249-44ae-98fe-e480f5f5ac2c-1767153103562.mp4
```