Fix console nginx: use variable upstreams for resilient DNS resolution

nginx crashes at startup if upstream hosts aren't resolvable yet.
Using 'set $upstream' + Docker's internal resolver (127.0.0.11)
defers DNS resolution to request time, so console starts even if
backends are still booting.
This commit is contained in:
2026-03-03 00:52:00 +00:00
parent 322a8d6a91
commit 0bf91e07eb

View File

@@ -8,6 +8,8 @@ RUN npm run build
FROM nginx:alpine FROM nginx:alpine
COPY --from=build /app/dist /usr/share/nginx/html COPY --from=build /app/dist /usr/share/nginx/html
COPY <<'EOF' /etc/nginx/conf.d/default.conf COPY <<'EOF' /etc/nginx/conf.d/default.conf
resolver 127.0.0.11 valid=10s;
server { server {
listen 80; listen 80;
root /usr/share/nginx/html; root /usr/share/nginx/html;
@@ -20,74 +22,89 @@ server {
# Auth routes → alert service (any service works, they all share auth) # Auth routes → alert service (any service works, they all share auth)
location /api/v1/auth/ { location /api/v1/auth/ {
proxy_pass http://alert:3000; set $upstream_alert alert:3000;
proxy_pass http://$upstream_alert;
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;
} }
# Drift API # Drift API
location /api/v1/stacks { location /api/v1/stacks {
proxy_pass http://drift:3000; set $upstream_drift drift:3000;
proxy_pass http://$upstream_drift;
proxy_set_header Host $host; proxy_set_header Host $host;
} }
location /api/v1/reports { location /api/v1/reports {
proxy_pass http://drift:3000; set $upstream_drift drift:3000;
proxy_pass http://$upstream_drift;
proxy_set_header Host $host; proxy_set_header Host $host;
} }
location /api/v1/dashboard { location /api/v1/dashboard {
proxy_pass http://drift:3000; set $upstream_drift drift:3000;
proxy_pass http://$upstream_drift;
proxy_set_header Host $host; proxy_set_header Host $host;
} }
# Alert API # Alert API
location /api/v1/incidents { location /api/v1/incidents {
proxy_pass http://alert:3000; set $upstream_alert alert:3000;
proxy_pass http://$upstream_alert;
proxy_set_header Host $host; proxy_set_header Host $host;
} }
location /api/v1/notifications { location /api/v1/notifications {
proxy_pass http://alert:3000; set $upstream_alert alert:3000;
proxy_pass http://$upstream_alert;
proxy_set_header Host $host; proxy_set_header Host $host;
} }
location /api/v1/webhooks { location /api/v1/webhooks {
proxy_pass http://alert:3000; set $upstream_alert alert:3000;
proxy_pass http://$upstream_alert;
proxy_set_header Host $host; proxy_set_header Host $host;
} }
# Portal API # Portal API
location /api/v1/services { location /api/v1/services {
proxy_pass http://portal:3000; set $upstream_portal portal:3000;
proxy_pass http://$upstream_portal;
proxy_set_header Host $host; proxy_set_header Host $host;
} }
# Cost API # Cost API
location /api/v1/anomalies { location /api/v1/anomalies {
proxy_pass http://cost:3000; set $upstream_cost cost:3000;
proxy_pass http://$upstream_cost;
proxy_set_header Host $host; proxy_set_header Host $host;
} }
location /api/v1/baselines { location /api/v1/baselines {
proxy_pass http://cost:3000; set $upstream_cost cost:3000;
proxy_pass http://$upstream_cost;
proxy_set_header Host $host; proxy_set_header Host $host;
} }
location /api/v1/governance { location /api/v1/governance {
proxy_pass http://cost:3000; set $upstream_cost cost:3000;
proxy_pass http://$upstream_cost;
proxy_set_header Host $host; proxy_set_header Host $host;
} }
location /api/v1/ingest { location /api/v1/ingest {
proxy_pass http://cost:3000; set $upstream_cost cost:3000;
proxy_pass http://$upstream_cost;
proxy_set_header Host $host; proxy_set_header Host $host;
} }
location /api/v1/cost { location /api/v1/cost {
proxy_pass http://cost:3000; set $upstream_cost cost:3000;
proxy_pass http://$upstream_cost;
proxy_set_header Host $host; proxy_set_header Host $host;
} }
# Run API # Run API
location /api/v1/runbooks { location /api/v1/runbooks {
proxy_pass http://run:3000; set $upstream_run run:3000;
proxy_pass http://$upstream_run;
proxy_set_header Host $host; proxy_set_header Host $host;
} }
location /api/v1/approvals { location /api/v1/approvals {
proxy_pass http://run:3000; set $upstream_run run:3000;
proxy_pass http://$upstream_run;
proxy_set_header Host $host; proxy_set_header Host $host;
} }
} }