From 6dc678bcd7c8298b2dae8d52ce1503543abf852e Mon Sep 17 00:00:00 2001 From: Linus Gasser Date: Fri, 20 Nov 2026 17:32:40 +0100 Subject: [PATCH] Resolve app upstream at request time in nginx nginx resolved the app hostname at startup and crashed with 'host not found in upstream' when the app task wasn't up yet. Use Docker's embedded DNS resolver with a variable upstream instead. Co-Authored-By: Claude Opus 5.5 --- abra.sh | 2 +- nginx.conf.tmpl | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/abra.sh b/abra.sh index d6da55f..0e6ed61 100644 --- a/abra.sh +++ b/abra.sh @@ -1,6 +1,6 @@ export CONFIG_VERSION=v3 export CONFIG_JS_VERSION=v2 -export NGINX_CONF_VERSION=v2 +export NGINX_CONF_VERSION=v3 export INFRA_JS_VERSION=v1 export SSO_ENTRYPOINT_VERSION=v8 export SSO_JS_VERSION=v3 diff --git a/nginx.conf.tmpl b/nginx.conf.tmpl index a8437d9..4f57e1a 100644 --- a/nginx.conf.tmpl +++ b/nginx.conf.tmpl @@ -7,9 +7,14 @@ server { #access_log /dev/null; #error_log /dev/null emerg; + # Resolve the app at request time via Docker's embedded DNS, so nginx + # doesn't crash at startup when the app task isn't up yet. + resolver 127.0.0.11 valid=10s ipv6=off; + set $cryptpad_upstream http://{{ env "STACK_NAME" }}_app:3000; + # Main CryptPad app location / { - proxy_pass http://{{ env "STACK_NAME" }}_app:3000; + proxy_pass $cryptpad_upstream; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; @@ -25,7 +30,7 @@ server { # WebSocket endpoint location ^~ /cryptpad_websocket { - proxy_pass http://{{ env "STACK_NAME" }}_app:3000; + proxy_pass $cryptpad_upstream; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr;