modified nginx mode
This commit is contained in:
@@ -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. 配置 Nginx 与 HTTPS
|
||||
## 4. 配置 Nginx(HTTP 回源)
|
||||
|
||||
本机 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
|
||||
|
||||
@@ -78,5 +78,6 @@ model is connected.
|
||||
python -m pytest sentence_api/tests -q
|
||||
```
|
||||
|
||||
See [DEPLOYMENT.md](DEPLOYMENT.md) for Docker, MOSS, Nginx, HTTPS, large-file
|
||||
See [DEPLOYMENT.md](DEPLOYMENT.md) for Docker, MOSS/Whisper, Nginx HTTP 回源,
|
||||
large-file
|
||||
upload, backup, and production operation instructions.
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
# 本机 Nginx 只提供 HTTP(端口 80),不在本机终结 HTTPS:
|
||||
# 证书由“总出口”(线上边缘网关)终结,网关把 https://video_service.d1kt.cn
|
||||
# 映射到本机内网 IP 的 80 端口,以 HTTP 回源。本机不需要证书,也不要监听 443。
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name video_service.d1kt.cn;
|
||||
@@ -12,7 +16,8 @@ server {
|
||||
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;
|
||||
# 透传边缘网关标记的原始协议(https);若网关不设置该头,可改回 $scheme
|
||||
proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
|
||||
proxy_request_buffering off;
|
||||
proxy_read_timeout 7200s;
|
||||
proxy_send_timeout 7200s;
|
||||
|
||||
Reference in New Issue
Block a user