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.
This commit is contained in:
2026-08-01 18:08:27 +02:00
parent 873627c757
commit f43ab711fd
+6 -1
View File
@@ -7,7 +7,12 @@ server {
} }
location /api/ { 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_http_version 1.1;
proxy_set_header Host $host; proxy_set_header Host $host;