fix: nginx resolves upstream at request time via Docker DNS

Nginx was crashing on startup because it tried to resolve the 'master'
hostname before the Spring Boot container was ready. Fixed by using
Docker's embedded DNS resolver (127.0.0.11) and a variable for
proxy_pass, which defers resolution to request time.
This commit is contained in:
vithobaa 2026-06-29 18:31:15 +05:30
parent a467069c9c
commit 9b4fe6677c
1 changed files with 6 additions and 2 deletions

View File

@ -5,6 +5,10 @@ server {
# Allow large request bodies (screenshots are base64 encoded) # Allow large request bodies (screenshots are base64 encoded)
client_max_body_size 50M; client_max_body_size 50M;
# Use Docker's internal DNS resolver resolves upstream at request time, not startup
resolver 127.0.0.11 valid=30s;
set $backend http://master:9090;
# Serve static files from the React build # Serve static files from the React build
location / { location / {
root /usr/share/nginx/html; root /usr/share/nginx/html;
@ -14,8 +18,8 @@ server {
# Reverse proxy API requests to the Master backend container # Reverse proxy API requests to the Master backend container
location /api/ { location /api/ {
proxy_pass http://master:9090; proxy_pass $backend;
# Standard proxy headers # Standard proxy headers
proxy_set_header Host $host; proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Real-IP $remote_addr;