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