From a8b22d8e2dd79039100e79377e97d8c1ac4b451b Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 19 Mar 2026 11:02:57 +0000 Subject: [PATCH] fix: switch to Caddy JSON config so dynamic routes work correctly The Caddyfile created a server with an auto-generated name, not 'hiy', so build.sh's PUT to /config/apps/http/servers/hiy/routes was creating a parallel server that never received traffic. - Replace Caddyfile with caddy.json that names the server 'hiy' with the dashboard as a catch-all fallback route - Insert app routes at index 0 so host-matched routes are evaluated before the catch-all dashboard fallback - Update docker-compose to mount caddy.json and pass --config flag --- builder/build.sh | 2 +- infra/docker-compose.yml | 3 ++- proxy/caddy.json | 24 ++++++++++++++++++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 proxy/caddy.json diff --git a/builder/build.sh b/builder/build.sh index 069034e..6568ca4 100755 --- a/builder/build.sh +++ b/builder/build.sh @@ -136,7 +136,7 @@ routes = [r for r in routes if not (isinstance(r, dict) and any(isinstance(m, dict) and new_host in m.get('host', []) for m in r.get('match', [])))] -routes.append(json.loads(sys.argv[1])) +routes.insert(0, json.loads(sys.argv[1])) print(json.dumps(routes)) " "$ROUTE_JSON") diff --git a/infra/docker-compose.yml b/infra/docker-compose.yml index 60d6e97..4b66238 100644 --- a/infra/docker-compose.yml +++ b/infra/docker-compose.yml @@ -43,9 +43,10 @@ services: - "443:443" - "2019:2019" # admin API volumes: - - ../proxy/Caddyfile:/etc/caddy/Caddyfile:ro + - ../proxy/caddy.json:/etc/caddy/caddy.json:ro - caddy-data:/data - caddy-config:/config + command: caddy run --config /etc/caddy/caddy.json networks: - hiy-net - default diff --git a/proxy/caddy.json b/proxy/caddy.json new file mode 100644 index 0000000..9284561 --- /dev/null +++ b/proxy/caddy.json @@ -0,0 +1,24 @@ +{ + "admin": { + "listen": "0.0.0.0:2019" + }, + "apps": { + "http": { + "servers": { + "hiy": { + "listen": [":80", ":443"], + "routes": [ + { + "handle": [ + { + "handler": "reverse_proxy", + "upstreams": [{"dial": "server:3000"}] + } + ] + } + ] + } + } + } + } +}