51 lines
1.7 KiB
Plaintext
51 lines
1.7 KiB
Plaintext
# ============================================================
|
||||
|
|
# Nginx 站点配置 —— api.trivoo.online 反向代理到 New API
|
|||
|
|
#
|
|||
|
|
# 目标路径:/etc/nginx/sites-available/api.trivoo.online
|
|||
|
|
# 启用:ln -s /etc/nginx/sites-available/api.trivoo.online \
|
|||
|
|
# /etc/nginx/sites-enabled/
|
|||
|
|
# nginx -t && systemctl reload nginx
|
|||
|
|
#
|
|||
|
|
# 先以 HTTP 建站跑通,再执行 sudo certbot --nginx
|
|||
|
|
# certbot 会自动把本文件改写成含 443 + 跳转的版本
|
|||
|
|
# ============================================================
|
|||
|
|
|
|||
|
|
map $http_upgrade $connection_upgrade {
|
|||
|
|
default upgrade;
|
|||
|
|
'' close;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
server {
|
|||
|
|
listen 80;
|
|||
|
|
listen [::]:80;
|
|||
|
|
server_name api.trivoo.online;
|
|||
|
|
|
|||
|
|
# 音频转录 / 图片编辑等大文件上传(Nginx 默认仅 1m,会 413)
|
|||
|
|
client_max_body_size 100m;
|
|||
|
|
|
|||
|
|
location / {
|
|||
|
|
proxy_pass http://127.0.0.1:3000;
|
|||
|
|
proxy_http_version 1.1;
|
|||
|
|
|
|||
|
|
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;
|
|||
|
|
|
|||
|
|
# WebSocket —— /v1/realtime 与 /v1/responses 需要
|
|||
|
|
proxy_set_header Upgrade $http_upgrade;
|
|||
|
|
proxy_set_header Connection $connection_upgrade;
|
|||
|
|
|
|||
|
|
# 流式响应(SSE)必须关闭缓冲,否则会被攒着一次性吐出
|
|||
|
|
proxy_buffering off;
|
|||
|
|
proxy_cache off;
|
|||
|
|
proxy_request_buffering off;
|
|||
|
|
|
|||
|
|
# 非流式请求要等上游生成完才返回响应头,超时给足
|
|||
|
|
proxy_read_timeout 1800s;
|
|||
|
|
proxy_send_timeout 1800s;
|
|||
|
|
send_timeout 1800s;
|
|||
|
|
|
|||
|
|
chunked_transfer_encoding on;
|
|||
|
|
}
|
|||
|
|
}
|