diff --git a/yunkes/nginx.conf b/yunkes/nginx.conf index a742879..85df655 100644 --- a/yunkes/nginx.conf +++ b/yunkes/nginx.conf @@ -24,8 +24,15 @@ server { # network; if the name changes, update here. Streaming endpoints # (/api/media/) work without buffering because we turn proxy_buffering # off — matches the dev-server behaviour (vite proxies /api/media first). + # + # DNS 加固(2026-09-04):nginx 默认启动时解析一次 hostname 并永久缓存, + # backend 重建/IP 漂移后 502(两天两次实战)。改用 docker 内嵌 DNS + # (127.0.0.11)按 TTL 重解析——variable proxy_pass 不带 URI,仍转发 + # 原始完整请求路径(/api/...),与原行为一致。 location /api/ { - proxy_pass http://backend:8000; + resolver 127.0.0.11 valid=10s ipv6=off; + set $yunke_backend http://backend:8000; + proxy_pass $yunke_backend; proxy_http_version 1.1; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr;