web: make the nginx resolver configurable so /api works off Docker
The /api location re-resolves BACKEND on every request, which needs a resolver address, and that address was hardcoded to 127.0.0.11 — Docker's embedded DNS. Nothing listens there on another runtime, and an unreachable resolver does not fail fast: every /api request hangs until it times out, with nothing in the error log to say why. On Kubernetes that means the app shell loads and the whole API is dead. RESOLVER now carries it, defaulting to 127.0.0.11 so Docker and every existing compose file are unchanged. Kubernetes sets it to the kube-dns service address; Podman to whatever its network provides. Documented next to the four other render-time settings in SELF_HOSTING.md, since it belongs to the same "fitting it into an existing stack" problem.
This commit is contained in:
1 parent
5c2005e81f
commit
2df725de84
4 files changed
+26
-5
No files matched your search
+11
-5
@@ -20,11 +20,17 @@ server {
|
||||
# as /api/anything.json would be matched by the \.(js|css|json|html)$ block instead and be
|
||||
# looked for on disk rather than proxied.
|
||||
location ^~ /api/ {
|
||||
# Resolved per request through Docker's DNS, not once at start-up: nginx otherwise pins
|
||||
# the api container's IP when it boots, and a recreated api (new IP) means 502 on every
|
||||
# /api call until web is restarted too (issue #16). The variable is what makes nginx
|
||||
# re-resolve; lowercase so the entrypoint's envsubst leaves it alone.
|
||||
resolver 127.0.0.11 valid=10s ipv6=off;
|
||||
# Resolved per request through the container runtime's DNS, not once at start-up: nginx
|
||||
# otherwise pins the api container's IP when it boots, and a recreated api (new IP) means
|
||||
# 502 on every /api call until web is restarted too (issue #16). The variable is what makes
|
||||
# nginx re-resolve; lowercase so the entrypoint's envsubst leaves it alone.
|
||||
#
|
||||
# RESOLVER defaults to Docker's embedded DNS, which is where this image usually runs.
|
||||
# Nothing answers on that address outside Docker, and an unreachable resolver does not
|
||||
# fail fast — every /api request hangs until it times out. Anywhere else, set RESOLVER to
|
||||
# the DNS the platform actually provides: on Kubernetes that is the kube-dns/CoreDNS
|
||||
# service address (`kubectl -n kube-system get svc kube-dns`, commonly 10.96.0.10).
|
||||
resolver ${RESOLVER} valid=10s ipv6=off;
|
||||
set $api_upstream http://${BACKEND}:${PORT};
|
||||
proxy_pass $api_upstream;
|
||||
proxy_http_version 1.1;
|
||||
|
||||
Reference in new issue
Block a user