diff --git a/deploy/nginx.conf b/deploy/nginx.conf index a25c096..719e892 100644 --- a/deploy/nginx.conf +++ b/deploy/nginx.conf @@ -2,11 +2,17 @@ server { listen 8080; server_name _; + # Docker embedded DNS, re-queried every 10s so rebuilt containers are picked up. + resolver 127.0.0.11 valid=10s; + root /usr/share/nginx/html; index index.html; location /api/ { - proxy_pass http://api:8080; + # Resolve `api` at request time: a rebuilt api container gets a new + # IP, and a startup-time-only DNS answer would pin nginx to it (502s). + set $api_upstream http://api:8080; + proxy_pass $api_upstream; proxy_http_version 1.1; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; @@ -14,7 +20,8 @@ server { } location = /health { - proxy_pass http://api:8080/health; + set $health_upstream http://api:8080; + proxy_pass $health_upstream/health; proxy_set_header Host $host; }