diff --git a/frontend/nginx.conf b/frontend/nginx.conf index 96a390a..e3f8d02 100644 --- a/frontend/nginx.conf +++ b/frontend/nginx.conf @@ -14,8 +14,15 @@ server { client_max_body_size 50m; # API reverse proxy -> FastAPI backend (port 8000) + # NOTE: upstream is resolved at REQUEST time through Docker's embedded DNS + # (127.0.0.11). A plain `proxy_pass http://api:8000` caches the container + # IP at nginx startup, so after the api container restarts and gets a new + # IP, nginx keeps proxying to the stale address (which may belong to + # another service) until this container is restarted too. location /api/ { - proxy_pass http://api:8000; + resolver 127.0.0.11 valid=10s ipv6=off; + set $api_upstream http://api:8000; + proxy_pass $api_upstream; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;