fix: bug: edge-control add_route targets non-existent Caddy server edge — registration succeeds in registry but traffic never routes (#789)
- install.sh: use Caddy `servers { name edge }` global option so the
emitted Caddyfile produces a predictably-named server
- lib/caddy.sh: add `_discover_server_name` that queries the admin API
for the first server listening on :80/:443 — add_route and remove_route
use dynamic discovery instead of hardcoding `/servers/edge/`
- lib/caddy.sh: add_route, remove_route, and reload_caddy now check HTTP
status codes (≥400 → return 1 with error message) instead of only
checking curl exit code
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
02e86c3589
commit
987413ab3a
2 changed files with 73 additions and 22 deletions
|
|
@ -225,13 +225,19 @@ EOF
|
|||
chmod 600 "$GANDI_ENV"
|
||||
|
||||
# Create Caddyfile with admin API and wildcard cert
|
||||
# The "servers" global option names the auto-generated server "edge" so that
|
||||
# lib/caddy.sh (which discovers the server dynamically) finds a predictable
|
||||
# name — defense-in-depth alongside the dynamic discovery in add_route.
|
||||
CADDYFILE="/etc/caddy/Caddyfile"
|
||||
cat > "$CADDYFILE" <<EOF
|
||||
cat > "$CADDYFILE" <<'CADDYEOF'
|
||||
# Caddy configuration for edge control plane
|
||||
# Admin API enabled on 127.0.0.1:2019
|
||||
|
||||
{
|
||||
admin localhost:2019
|
||||
servers {
|
||||
name edge
|
||||
}
|
||||
}
|
||||
|
||||
# Default site (reverse proxy for edge tunnels will be added dynamically)
|
||||
|
|
@ -240,7 +246,7 @@ cat > "$CADDYFILE" <<EOF
|
|||
dns gandi {env.GANDI_API_KEY}
|
||||
}
|
||||
}
|
||||
EOF
|
||||
CADDYEOF
|
||||
|
||||
# Start Caddy
|
||||
systemctl restart caddy 2>/dev/null || {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue