Resolve app upstream at request time in nginx
continuous-integration/drone/push Build is failing

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 <noreply@anthropic.com>
This commit was merged in pull request #15.
This commit is contained in:
Linus Gasser
2026-11-24 08:24:22 +00:00
committed by ineiti
co-authored by Claude Opus 5.5
parent c361d4eba8
commit 6dc678bcd7
2 changed files with 8 additions and 3 deletions
+1 -1
View File
@@ -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
+7 -2
View File
@@ -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;