Document public reverse proxy deployment
- Add README instructions for deploying the full report system through local Docker port 4002, frpc, Nginx Proxy Manager, and sstwbg.example.com. - Document required HTTPS, WebSocket, request-size, timeout, health-check, login, AI, video-frame, and speech verification steps. - Add TRUST_PROXY support so secure session cookies work behind public HTTPS reverse proxies. - Preserve upstream X-Forwarded-Proto through the container Nginx API proxy. - Allow Docker Compose session and trust-proxy variables to be overridden for public deployments. - Update deployment and Docker docs with the same public reverse-proxy guidance.
This commit is contained in:
79
README.md
79
README.md
@@ -126,6 +126,7 @@ cp .env.example .env.local
|
||||
- `DATABASE_URL`:PostgreSQL 连接串。Docker Compose 暴露到宿主机的默认端口是 `5433`,容器内部仍使用 `db:5432`。
|
||||
- `SESSION_SECRET`:后端 Session Cookie 签名密钥,生产环境必须替换。
|
||||
- `SESSION_COOKIE_SECURE`:是否只通过 HTTPS 发送 Session Cookie。本地 HTTP/Compose 默认 `false`。
|
||||
- `TRUST_PROXY`:是否信任反向代理传入的 `X-Forwarded-*` 头。`# XXX` 公网 HTTPS 经过 Nginx Proxy Manager、frpc/frps 或其他反向代理转发时建议设为 `true`,否则 `SESSION_COOKIE_SECURE=true` 时登录 Cookie 可能无法正确写入。
|
||||
- `FILE_STORAGE_DIR`:后端文件存储目录。Docker Compose 默认挂载到 `/app/uploads`。
|
||||
- `VITE_API_PROXY_TARGET`:Vite 开发服务器的 `/api` 代理目标。直接运行 `npm run server:dev` 时用 `http://localhost:3100`;连接 Docker Compose API 时用 `http://localhost:3002`。
|
||||
- `VITE_ENABLE_LOCAL_FALLBACK`:是否允许生产构建继续使用浏览器本地兼容回退。开发模式默认启用,生产默认关闭。
|
||||
@@ -248,6 +249,84 @@ docker-compose down
|
||||
- `nginx.conf` 已支持 `/api/speech/iat` WebSocket upgrade。
|
||||
完整 Docker 说明见 [docs/docker.md](./docs/docker.md)。
|
||||
|
||||
## 公网反向代理部署
|
||||
|
||||
<!-- # XXX 公网部署新增:适用于本机 Docker 4002 端口通过 frpc 映射到公网服务器,再由 Nginx Proxy Manager 绑定 sstwbg.example.com 的部署链路。 -->
|
||||
|
||||
推荐公网链路:
|
||||
|
||||
```text
|
||||
浏览器 https://sstwbg.example.com
|
||||
-> 公网服务器 Nginx Proxy Manager
|
||||
-> frps/frpc 映射端口
|
||||
-> 本机 Docker web:4002
|
||||
-> 容器 Nginx /api 代理
|
||||
-> api:3100
|
||||
```
|
||||
|
||||
本机部署并确认 Docker 服务正常:
|
||||
|
||||
```bash
|
||||
# XXX 在部署机器上使用当前最新版分支。
|
||||
git fetch origin
|
||||
git checkout surclaw-system-backendized-20260502
|
||||
git pull --ff-only origin surclaw-system-backendized-20260502
|
||||
|
||||
# XXX 公网 HTTPS 部署建议替换 Session 密钥,并信任外层反向代理。
|
||||
export SESSION_SECRET="替换为足够长的随机字符串"
|
||||
export SESSION_COOKIE_SECURE="true"
|
||||
export TRUST_PROXY="true"
|
||||
|
||||
docker-compose up -d --build
|
||||
curl http://127.0.0.1:4002/api/health
|
||||
```
|
||||
|
||||
如果使用 frpc 把本机 `4002` 映射到公网服务器,示例配置如下,端口号按你的 frps 实际开放端口调整:
|
||||
|
||||
```toml
|
||||
# XXX frpc 示例:把本机 Docker 前端入口 4002 暴露到公网服务器的一个内网监听端口。
|
||||
[[proxies]]
|
||||
name = "surclaw-web"
|
||||
type = "tcp"
|
||||
localIP = "127.0.0.1"
|
||||
localPort = 4002
|
||||
remotePort = 4002
|
||||
```
|
||||
|
||||
Nginx Proxy Manager 中为 `sstwbg.example.com` 新建 Proxy Host:
|
||||
|
||||
- `Domain Names`:`sstwbg.example.com`
|
||||
- `Scheme`:`http`
|
||||
- `Forward Hostname / IP`:frps 可访问到的映射地址,通常是 `127.0.0.1`、公网服务器内网 IP 或 frps 指定监听地址。
|
||||
- `Forward Port`:frpc 暴露出来的 `remotePort`,例如 `4002`。
|
||||
- `Websockets Support`:开启。`# XXX` 语音识别使用 `/api/speech/iat` WebSocket,必须透传 Upgrade。
|
||||
- `Block Common Exploits`:开启。
|
||||
- `SSL`:申请或绑定 `sstwbg.example.com` 证书,开启 `Force SSL`。`# XXX` 浏览器麦克风权限要求 HTTPS,普通公网 HTTP 下语音识别不可用。
|
||||
|
||||
Nginx Proxy Manager 的 `Advanced` 可加入:
|
||||
|
||||
```nginx
|
||||
# XXX 图文报告、关键帧和模板图片可能较大,公网代理请求体上限需与容器 Nginx/API 保持一致。
|
||||
client_max_body_size 100m;
|
||||
|
||||
# XXX WebSocket 语音听写需要较长连接时间。
|
||||
proxy_read_timeout 3600s;
|
||||
proxy_send_timeout 3600s;
|
||||
```
|
||||
|
||||
公网验收顺序:
|
||||
|
||||
```text
|
||||
1. 打开 https://sstwbg.example.com/api/health,确认 API 健康检查可访问。
|
||||
2. 打开 https://sstwbg.example.com 登录 admin / 123456。
|
||||
3. 进入系统设置,确认 AI Provider 和讯飞语音配置有效。
|
||||
4. 进入报告编辑页,测试上传视频、自动抽帧、报告保存、AI 对话和语音听写。
|
||||
5. 浏览器控制台执行 window.isSecureContext,应返回 true;否则语音麦克风权限不会开放。
|
||||
```
|
||||
|
||||
如果登录失败或刷新后掉登录,优先检查 `SESSION_SECRET` 是否稳定、`SESSION_COOKIE_SECURE=true` 时是否同时设置了 `TRUST_PROXY=true`,以及外层 NPM 是否把 `X-Forwarded-Proto: https` 传给后端链路。
|
||||
如果只有语音识别失败,优先检查 NPM 的 `Websockets Support`、HTTPS 证书、浏览器麦克风权限、系统设置中的讯飞 APPID/APIKey/APISecret,以及后端容器是否能访问讯飞 `wss://iat-api.xfyun.cn/v2/iat`。
|
||||
|
||||
## 当前限制
|
||||
|
||||
- 前端登录、工作台统计、报告读写、报告媒体引用、模板读写、字段库、模板图片资源、视频/关键帧文件、用户管理、部门模板授权、系统设置、签名文件、AI 对话和语音听写已接入真实后端 Session/API/代理。
|
||||
|
||||
Reference in New Issue
Block a user