From f43ab711fd780d355581416dbdb0fc51eb17b770 Mon Sep 17 00:00:00 2001 From: nessi Date: Sat, 1 Aug 2026 18:08:27 +0200 Subject: [PATCH] Fix Nginx backend proxy resolution and prevent startup failures Added dynamic DNS resolution for the backend service to prevent Nginx from failing when the backend container is not yet available during startup. Implemented Docker's internal resolver with a 10-second validity period and moved the backend URL to a variable for runtime resolution. Replaced direct proxy_pass with rewrite rule for proper path handling. --- frontend/nginx.conf | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/frontend/nginx.conf b/frontend/nginx.conf index 5e86569..2297cff 100644 --- a/frontend/nginx.conf +++ b/frontend/nginx.conf @@ -7,7 +7,12 @@ server { } location /api/ { - proxy_pass http://backend:8080/; + # Resolve the Docker service at request time. This prevents Nginx from + # exiting when the Docker DNS entry is not ready during container startup. + resolver 127.0.0.11 ipv6=off valid=10s; + set $backend_upstream http://backend:8080; + rewrite ^/api/(.*)$ /$1 break; + proxy_pass $backend_upstream; proxy_http_version 1.1; proxy_set_header Host $host;