44 lines
1.7 KiB
Plaintext
44 lines
1.7 KiB
Plaintext
# zcbot nginx 反代示例(蓝绿双实例,RUN.md §无感更新 B 档)。
|
|
#
|
|
# 安装(一次性):
|
|
# sudo cp deploy/nginx/zcbot.conf.example /etc/nginx/conf.d/zcbot.conf # 按需改 server_name/端口/TLS
|
|
# echo 'server 127.0.0.1:8765;' | sudo tee /etc/nginx/zcbot_upstream.conf # 初始指 blue
|
|
# sudo nginx -t && sudo systemctl reload nginx
|
|
#
|
|
# 之后 zcbot_upstream.conf 由 deploy/update_bluegreen.sh 改写 + reload nginx 切流量,
|
|
# 本文件不再动。nginx reload 对已建立连接零影响:旧 SSE 留在旧实例自然收尾,新请求走新实例。
|
|
|
|
upstream zcbot_backend {
|
|
# 只含一行 server 127.0.0.1:8765|8766;由 update_bluegreen.sh 维护
|
|
include /etc/nginx/zcbot_upstream.conf;
|
|
keepalive 32;
|
|
}
|
|
|
|
server {
|
|
listen 80;
|
|
# TODO 按部署域名改;上 TLS 时换 listen 443 ssl + 证书(certbot 等)
|
|
server_name _;
|
|
|
|
# 上传接口(/v1/files/upload)会传大文件;与后端无硬限制,给足余量
|
|
client_max_body_size 512m;
|
|
|
|
location / {
|
|
proxy_pass http://zcbot_backend;
|
|
proxy_http_version 1.1;
|
|
# keepalive upstream 需要清掉 Connection 头
|
|
proxy_set_header Connection "";
|
|
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;
|
|
|
|
# ★ SSE(GET /v1/tasks/{id}/events):关 buffering、拉长 read 超时。
|
|
# 后端响应头已带 X-Accel-Buffering: no(对 proxy_buffering 同效),这里显式
|
|
# 再关一层作双保险;30s 服务端 ping 心跳 < read_timeout,长连接不会被掐。
|
|
proxy_buffering off;
|
|
proxy_cache off;
|
|
proxy_read_timeout 3600s;
|
|
proxy_send_timeout 3600s;
|
|
}
|
|
}
|