nginx resolves a variable `proxy_pass` upstream itself, using only the `resolver` directive and never the search domains in /etc/resolv.conf. That cost two workarounds in one script: rewriting the resolver address for rootless podman (Docker's 127.0.0.11 is wrong there), and injecting a full FQDN so the bare `bff` name could resolve on Kubernetes at all. Caddy dials its upstream per request through the system resolver, which reads nameserver *and* search domains, so `reverse_proxy bff:8080` resolves on every engine with no per-engine configuration — and it still starts before the BFF exists and picks up its restarts. Both workarounds are deleted with the script. Routing uses mutually-exclusive `handle` blocks, not a bare `try_files`: Caddy sorts rewrites *before* reverse_proxy, so a top-level SPA fallback would rewrite every API path to /index.html before the proxy saw it.
22 lines
862 B
Caddyfile
22 lines
862 B
Caddyfile
:80 {
|
|
# Same-origin API: beheerders use the same medewerker realm as behandel (S-15a).
|
|
# `handle` blocks are mutually exclusive and matched most-specific-first, so the
|
|
# SPA fallback below can never swallow an API call — unlike a bare `try_files`,
|
|
# which Caddy sorts *before* reverse_proxy and would rewrite it to /index.html.
|
|
#
|
|
# No `resolver` stanza is needed: Caddy dials the upstream per
|
|
# request through the system resolver, so it starts before the BFF is up, picks up
|
|
# its restarts, and honours the DNS search domains in /etc/resolv.conf — which is
|
|
# what lets the bare `bff` name resolve on Kubernetes as well as under compose.
|
|
handle /beheer/* {
|
|
reverse_proxy bff:8080
|
|
}
|
|
|
|
# The Angular app. Client-side routing: an unknown path serves index.html.
|
|
handle {
|
|
root * /usr/share/caddy
|
|
try_files {path} /index.html
|
|
file_server
|
|
}
|
|
}
|