From 83d0347ca71608da04fd1f5b96386d3c05c3cf39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A7=9A=E7=AB=A0=E6=B5=A9?= Date: Tue, 15 Sep 2026 11:45:37 +0800 Subject: [PATCH] =?UTF-8?q?fix(web):=20=E8=AF=B7=E6=B1=82=E6=97=B6?= =?UTF-8?q?=E8=A7=A3=E6=9E=90=20api=20=E4=B8=8A=E6=B8=B8=E4=BB=A5=E5=85=8D?= =?UTF-8?q?=E9=87=8D=E5=BB=BA=E5=90=8E=20502?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deploy/nginx.conf | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/deploy/nginx.conf b/deploy/nginx.conf index a25c096..719e892 100644 --- a/deploy/nginx.conf +++ b/deploy/nginx.conf @@ -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; }