Skip to content

Commit 211789a

Browse files
committed
Fix nginx collab resolver to work under podman/netavark
The /collab/ resolver was hardcoded to Docker's embedded DNS (127.0.0.11), which doesn't exist under podman/netavark where aardvark-dns listens on the network gateway instead. This silently 502s every /collab/ request after a 30s timeout on podman stacks. Read the real nameserver from the container's own /etc/resolv.conf at startup instead.
1 parent 454a302 commit 211789a

2 files changed

Lines changed: 25 additions & 8 deletions

File tree

docker/nginx/entrypoint.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,18 @@ if [ -n "${SERVER_NAME:-}" ]; then
4646
export SERVER_NAME
4747
fi
4848

49+
# The /collab/ location resolves its upstream at request time so nginx
50+
# doesn't refuse to start when the (optional) collab service is absent.
51+
# The resolver address is container-runtime-specific: Docker's embedded
52+
# DNS is always 127.0.0.11, but podman/netavark's aardvark-dns listens on
53+
# the network gateway instead. Read the real nameserver out of this
54+
# container's own /etc/resolv.conf so both runtimes work.
55+
DNS_RESOLVER=$(awk '/^nameserver/{print $2; exit}' /etc/resolv.conf)
56+
export DNS_RESOLVER="${DNS_RESOLVER:-127.0.0.11}"
57+
4958
# envsubst will make a substitution on every $variable in a file, since the nginx file contains nginx variable like $host, we have to limit the substitution to this set
5059
# otherwise, each nginx variable will be replaced by an empty string
51-
envsubst '${INTERFACE_HTTPS_PORT} ${IRIS_UPSTREAM_SERVER} ${IRIS_UPSTREAM_PORT} ${SERVER_NAME} ${KEY_FILENAME} ${CERT_FILENAME} ${IRIS_FRONTEND_SERVER} ${IRIS_FRONTEND_PORT}' < /etc/nginx/nginx.conf > /tmp/nginx.conf
60+
envsubst '${INTERFACE_HTTPS_PORT} ${IRIS_UPSTREAM_SERVER} ${IRIS_UPSTREAM_PORT} ${SERVER_NAME} ${KEY_FILENAME} ${CERT_FILENAME} ${IRIS_FRONTEND_SERVER} ${IRIS_FRONTEND_PORT} ${DNS_RESOLVER}' < /etc/nginx/nginx.conf > /tmp/nginx.conf
5261
cp /tmp/nginx.conf /etc/nginx/nginx.conf
5362
rm /tmp/nginx.conf
5463

docker/nginx/nginx.conf

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -155,13 +155,21 @@ http {
155155
}
156156

157157
location /collab/ {
158-
# Resolve at request time (Docker's embedded DNS) instead of at
159-
# nginx startup: the collab service is a BV-only optional
160-
# feature and isn't present in every compose stack (e.g. the
161-
# upstream-derived dev/CI stack). A static proxy_pass hostname
162-
# would make nginx refuse to start entirely when "collab" can't
163-
# be resolved; this way only /collab/ requests fail if it's absent.
164-
resolver 127.0.0.11 valid=30s;
158+
# Resolve at request time (the container's own DNS resolver)
159+
# instead of at nginx startup: the collab service is a BV-only
160+
# optional feature and isn't present in every compose stack (e.g.
161+
# the upstream-derived dev/CI stack). A static proxy_pass
162+
# hostname would make nginx refuse to start entirely when
163+
# "collab" can't be resolved; this way only /collab/ requests
164+
# fail if it's absent.
165+
#
166+
# ${DNS_RESOLVER} is templated by entrypoint.sh from the
167+
# container's /etc/resolv.conf. It is NOT hardcoded to Docker's
168+
# embedded-DNS address (127.0.0.11) because that address doesn't
169+
# exist under podman/netavark, where aardvark-dns listens on the
170+
# network gateway instead — a hardcoded 127.0.0.11 here silently
171+
# 502s every /collab/ request after a 30s resolver timeout.
172+
resolver ${DNS_RESOLVER} valid=30s;
165173
set $collab_upstream collab;
166174

167175
proxy_set_header Host $http_host;

0 commit comments

Comments
 (0)