From 08d7d19d0efdd3fef6694aa7b9f7c484bb6e2e87 Mon Sep 17 00:00:00 2001 From: jlightner Date: Mon, 30 Mar 2026 05:55:42 -0500 Subject: [PATCH] =?UTF-8?q?fix:=20Nginx=20resolver=20for=20Docker=20DNS=20?= =?UTF-8?q?=E2=80=94=20prevent=20stale=20upstream=20IPs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use Docker embedded DNS (127.0.0.11) with 30s TTL and variable-based proxy_pass so nginx re-resolves the API container IP after recreates instead of caching the startup IP forever. Co-Authored-By: Claude Opus 4.6 (1M context) --- docker/nginx.conf | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/docker/nginx.conf b/docker/nginx.conf index 8efc8a8..3dd642d 100644 --- a/docker/nginx.conf +++ b/docker/nginx.conf @@ -4,14 +4,19 @@ server { root /usr/share/nginx/html; index index.html; + # Use Docker's embedded DNS with 30s TTL so upstream IPs refresh + # after container recreates + resolver 127.0.0.11 valid=30s ipv6=off; + # SPA fallback location / { try_files $uri $uri/ /index.html; } - # API proxy + # API proxy — variable forces nginx to re-resolve on each request location /api/ { - proxy_pass http://chrysopedia-api:8000; + set $backend http://chrysopedia-api:8000; + proxy_pass $backend; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; @@ -19,6 +24,7 @@ server { } location /health { - proxy_pass http://chrysopedia-api:8000; + set $backend http://chrysopedia-api:8000; + proxy_pass $backend; } }