modified nginx mode

This commit is contained in:
2026-08-16 16:29:13 +08:00
parent 2d48c127f9
commit c90df866c1
3 changed files with 22 additions and 8 deletions

View File

@@ -30,7 +30,7 @@
| MOSS | `127.0.0.1:8001` | 内部语音转写 |
| Whisper | `127.0.0.1:9000` | 内部语音转写Whisper 方案,见第 2A 节) |
| FastAPI | `127.0.0.1:8000` | 内部应用服务 |
| Nginx | `0.0.0.0:443` | 对 HTTPS |
| Nginx | `0.0.0.0:80` | 对 HTTP 回源HTTPS 由总出口终结) |
不要把 MOSS/Whisper 的转写端口直接暴露到公网。
@@ -238,7 +238,11 @@ sudo journalctl -u oral-trainer-api -f
当前上传后的处理任务运行在 API 进程中,因此只能使用一个 Uvicorn worker。需要多机或多 worker 时,应把 `VideoProcessor.process` 迁移到 Celery、RQ 或其他持久化任务队列。
## 4. 配置 NginxHTTPS
## 4. 配置 NginxHTTP 回源)
本机 Nginx 只监听 80 端口提供 HTTP不在本机终结 HTTPS。总出口线上边缘网关
`https://video_service.d1kt.cn` 终结 TLS 证书后,把请求以 HTTP 转发到本机
内网 IP 的 80 端口。因此本机不需要证书,也不需要安装 certbot。
```bash
sudo cp sentence_api/nginx.conf.example /etc/nginx/sites-available/oral-trainer
@@ -253,20 +257,24 @@ sudo systemctl reload nginx
- `proxy_request_buffering off`:上传时直接流向 FastAPI避免 Nginx 再完整缓存一份。
- `proxy_force_ranges on`:保留 Android 随机拖动播放所需的 HTTP Range。
- `proxy_read_timeout 7200s`:允许长视频处理和慢速上传。
- `X-Forwarded-Proto`透传边缘网关标记的原始协议https让 API 在需要时能识别
用户实际走的 HTTPS若网关不设置该头可把配置改回 `$scheme`
签发证书
本地验证(走本机 Nginx
```bash
sudo apt install -y certbot python3-certbot-nginx
sudo certbot --nginx -d video_service.d1kt.cn
curl -H 'Host: video_service.d1kt.cn' http://127.0.0.1/healthz
```
证书完成后验证:
公网验证(经总出口映射,需先在网关配置好 `https://video_service.d1kt.cn`
到本机内网 IP:80 的映射):
```bash
curl https://video_service.d1kt.cn/healthz
```
证书的申请与续期都在总出口完成,本机无需任何证书配置。
管理后台地址:
```text