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
This commit is contained in:
parent
11db59d612
commit
a8b22d8e2d
3 changed files with 27 additions and 2 deletions
|
|
@ -136,7 +136,7 @@ routes = [r for r in routes
|
||||||
if not (isinstance(r, dict)
|
if not (isinstance(r, dict)
|
||||||
and any(isinstance(m, dict) and new_host in m.get('host', [])
|
and any(isinstance(m, dict) and new_host in m.get('host', [])
|
||||||
for m in r.get('match', [])))]
|
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))
|
print(json.dumps(routes))
|
||||||
" "$ROUTE_JSON")
|
" "$ROUTE_JSON")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,9 +43,10 @@ services:
|
||||||
- "443:443"
|
- "443:443"
|
||||||
- "2019:2019" # admin API
|
- "2019:2019" # admin API
|
||||||
volumes:
|
volumes:
|
||||||
- ../proxy/Caddyfile:/etc/caddy/Caddyfile:ro
|
- ../proxy/caddy.json:/etc/caddy/caddy.json:ro
|
||||||
- caddy-data:/data
|
- caddy-data:/data
|
||||||
- caddy-config:/config
|
- caddy-config:/config
|
||||||
|
command: caddy run --config /etc/caddy/caddy.json
|
||||||
networks:
|
networks:
|
||||||
- hiy-net
|
- hiy-net
|
||||||
- default
|
- default
|
||||||
|
|
|
||||||
24
proxy/caddy.json
Normal file
24
proxy/caddy.json
Normal file
|
|
@ -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"}]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Reference in a new issue