fix(web): 请求时解析 api 上游以免重建后 502

This commit is contained in:
姚章浩
2026-09-15 11:45:37 +08:00
parent c84f848849
commit 83d0347ca7
+9 -2
View File
@@ -2,11 +2,17 @@ server {
listen 8080;
server_name _;
# Docker embedded DNS, re-queried every 10s so rebuilt containers are picked up.
resolver 127.0.0.11 valid=10s;
root /usr/share/nginx/html;
index index.html;
location /api/ {
proxy_pass http://api:8080;
# Resolve `api` at request time: a rebuilt api container gets a new
# IP, and a startup-time-only DNS answer would pin nginx to it (502s).
set $api_upstream http://api:8080;
proxy_pass $api_upstream;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
@@ -14,7 +20,8 @@ server {
}
location = /health {
proxy_pass http://api:8080/health;
set $health_upstream http://api:8080;
proxy_pass $health_upstream/health;
proxy_set_header Host $host;
}