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:
@@ -64,6 +64,7 @@ AI 和语音密钥由后端 Settings API 保存并由代理使用,前端不再
|
||||
- `DATABASE_URL`:PostgreSQL 连接串。Docker Compose 暴露到宿主机的默认端口是 `5433`,容器内部仍使用 `db:5432`。
|
||||
- `SESSION_SECRET`:Session Cookie 签名密钥。
|
||||
- `SESSION_COOKIE_SECURE`:是否只通过 HTTPS 发送 Session Cookie。本地 HTTP/Compose 默认 `false`,生产 HTTPS 应设为 `true`。
|
||||
- `TRUST_PROXY`:是否信任反向代理传入的 `X-Forwarded-*` 头。`# XXX` 公网 HTTPS 经过 Nginx Proxy Manager、frpc/frps 或其他反向代理转发时建议设为 `true`。
|
||||
- `FILE_STORAGE_DIR`:后端文件目录。Docker Compose 默认 `/app/uploads`,并挂载到 `uploads_data` volume。
|
||||
- `RUN_DB_MIGRATIONS`:Docker API 容器启动时是否执行 `prisma migrate deploy`,默认 `true`。
|
||||
- `RUN_DB_SEED`:Docker API 容器启动时是否执行 `prisma db seed`,默认 `true`。
|
||||
@@ -97,6 +98,38 @@ docker-compose up -d --build
|
||||
|
||||
更完整的 Docker 说明、生产变量、证书和备份恢复见 [Docker 化部署](./docker.md)。
|
||||
|
||||
## 公网反向代理
|
||||
|
||||
<!-- # XXX 公网部署新增:适用于本机 Docker 4002 端口经 frpc 映射到公网服务器,再由 Nginx Proxy Manager 绑定域名。 -->
|
||||
|
||||
推荐链路:
|
||||
|
||||
```text
|
||||
浏览器 https://sstwbg.example.com
|
||||
-> 公网服务器 Nginx Proxy Manager
|
||||
-> frps/frpc 映射端口
|
||||
-> 本机 Docker web:4002
|
||||
-> 容器 Nginx /api
|
||||
-> api:3100
|
||||
```
|
||||
|
||||
公网部署建议变量:
|
||||
|
||||
```bash
|
||||
# XXX HTTPS 生产入口建议开启安全 Cookie,并让后端信任外层代理协议头。
|
||||
export SESSION_SECRET="替换为足够长的随机字符串"
|
||||
export SESSION_COOKIE_SECURE="true"
|
||||
export TRUST_PROXY="true"
|
||||
docker-compose up -d --build
|
||||
```
|
||||
|
||||
Nginx Proxy Manager 代理 `sstwbg.example.com` 时:
|
||||
|
||||
- 代理目标指向 frpc 暴露的 `4002` 映射端口。
|
||||
- 开启 `Websockets Support`,否则 `/api/speech/iat` 语音 WebSocket 会失败。
|
||||
- 绑定 SSL 证书并开启 `Force SSL`,否则浏览器不会开放公网麦克风权限。
|
||||
- Advanced 中建议设置 `client_max_body_size 100m;`、`proxy_read_timeout 3600s;`、`proxy_send_timeout 3600s;`。
|
||||
|
||||
## 麦克风访问
|
||||
|
||||
浏览器不允许普通局域网 HTTP 页面调用麦克风,代码无法绕过这个限制。Docker 演示环境建议使用:
|
||||
|
||||
@@ -110,8 +110,34 @@ https://localhost:4443
|
||||
- 使用医院内网域名。
|
||||
- 通过可信 CA 或内网 CA 签发证书。
|
||||
- 把 `SESSION_COOKIE_SECURE` 设为 `true`。
|
||||
- 把 `TRUST_PROXY` 设为 `true`。`# XXX` 如果 HTTPS 在 Nginx Proxy Manager、frpc/frps 等外层代理终止,后端需要信任 `X-Forwarded-Proto` 才能正确写入安全 Cookie。
|
||||
- 把 `CORS_ORIGIN` 改成真实前端 HTTPS 来源。
|
||||
|
||||
## 公网域名反向代理
|
||||
|
||||
<!-- # XXX 公网部署新增:适用于本机 Docker 4002 端口经 frpc 映射到公网服务器,再由 Nginx Proxy Manager 绑定 sstwbg.example.com。 -->
|
||||
|
||||
如果使用 `本机 Docker 4002 -> frpc -> 公网服务器 Nginx Proxy Manager -> sstwbg.example.com`,推荐流程:
|
||||
|
||||
```bash
|
||||
# XXX 使用公网 HTTPS 入口时,compose 变量可从 shell 或 .env 覆盖。
|
||||
export SESSION_SECRET="替换为足够长的随机字符串"
|
||||
export SESSION_COOKIE_SECURE="true"
|
||||
export TRUST_PROXY="true"
|
||||
docker-compose up -d --build
|
||||
```
|
||||
|
||||
Nginx Proxy Manager 配置要点:
|
||||
|
||||
- `Domain Names` 使用 `sstwbg.example.com`。
|
||||
- `Forward Hostname / IP` 指向 frpc 在公网服务器暴露的地址。
|
||||
- `Forward Port` 填 frpc 暴露的端口,例如 `4002`。
|
||||
- 开启 `Websockets Support`,保证 `/api/speech/iat` 语音听写 WebSocket 可升级。
|
||||
- SSL 页签绑定证书并开启 `Force SSL`,保证浏览器开放麦克风权限。
|
||||
- Advanced 中建议设置 `client_max_body_size 100m;`、`proxy_read_timeout 3600s;`、`proxy_send_timeout 3600s;`。
|
||||
|
||||
公网验收先访问 `https://sstwbg.example.com/api/health`,再登录并测试报告保存、视频抽帧、AI 对话和语音听写。
|
||||
|
||||
## 生产部署前必须修改
|
||||
|
||||
`docker-compose.yaml` 当前适合演示和院内试运行,生产前至少修改:
|
||||
@@ -121,6 +147,7 @@ https://localhost:4443
|
||||
- `SESSION_SECRET`:替换为高强度随机值。
|
||||
- `CORS_ORIGIN`:只保留真实前端来源。
|
||||
- `SESSION_COOKIE_SECURE`:HTTPS 部署时设为 `true`。
|
||||
- `TRUST_PROXY`:经反向代理提供 HTTPS 时设为 `true`。
|
||||
- `RUN_DB_SEED`:不需要每次启动 seed 时可设为 `false`。
|
||||
- AI/讯飞演示凭据:通过系统设置替换为正式凭据;已经暴露过的密钥应轮换。
|
||||
- HTTPS 证书:替换自签名本机证书。
|
||||
|
||||
Reference in New Issue
Block a user