fix: infra: edge-control install.sh overwrites /etc/caddy/Caddyfile with no carve-out for apex/static sites — landing page lost on install (#788)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
182c40b9fc
commit
5a2a9e1c74
2 changed files with 60 additions and 7 deletions
|
|
@ -83,9 +83,12 @@ curl -sL https://raw.githubusercontent.com/disinto-admin/disinto/fix/issue-621/t
|
||||||
- Permissions: `root:disinto-register 0750`
|
- Permissions: `root:disinto-register 0750`
|
||||||
|
|
||||||
3. **Installs Caddy**:
|
3. **Installs Caddy**:
|
||||||
|
- Backs up any pre-existing `/etc/caddy/Caddyfile` to `/etc/caddy/Caddyfile.pre-disinto`
|
||||||
- Download Caddy with Gandi DNS plugin
|
- Download Caddy with Gandi DNS plugin
|
||||||
- Enable admin API on `127.0.0.1:2019`
|
- Enable admin API on `127.0.0.1:2019`
|
||||||
- Configure wildcard cert for `*.disinto.ai` via DNS-01
|
- Configure wildcard cert for `*.disinto.ai` via DNS-01
|
||||||
|
- Creates `/etc/caddy/extra.d/` for operator-owned site blocks
|
||||||
|
- Emitted Caddyfile ends with `import /etc/caddy/extra.d/*.caddy`
|
||||||
|
|
||||||
4. **Sets up SSH**:
|
4. **Sets up SSH**:
|
||||||
- Creates `disinto-register` authorized_keys with forced command
|
- Creates `disinto-register` authorized_keys with forced command
|
||||||
|
|
@ -95,6 +98,27 @@ curl -sL https://raw.githubusercontent.com/disinto-admin/disinto/fix/issue-621/t
|
||||||
- `/opt/disinto-edge/register.sh` — forced command handler
|
- `/opt/disinto-edge/register.sh` — forced command handler
|
||||||
- `/opt/disinto-edge/lib/*.sh` — helper libraries
|
- `/opt/disinto-edge/lib/*.sh` — helper libraries
|
||||||
|
|
||||||
|
## Operator-Owned Site Blocks
|
||||||
|
|
||||||
|
Edge-control owns the top-level `/etc/caddy/Caddyfile` and dynamic `<project>.<DOMAIN_SUFFIX>` routes injected via the Caddy admin API. Operators own everything under `/etc/caddy/extra.d/`.
|
||||||
|
|
||||||
|
To serve non-tunnel content (apex domain, www redirect, static sites), drop `.caddy` files into `/etc/caddy/extra.d/`:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Example: /etc/caddy/extra.d/landing.caddy
|
||||||
|
disinto.ai {
|
||||||
|
root * /home/debian/disinto-site
|
||||||
|
file_server
|
||||||
|
}
|
||||||
|
|
||||||
|
# Example: /etc/caddy/extra.d/www-redirect.caddy
|
||||||
|
www.disinto.ai {
|
||||||
|
redir https://disinto.ai{uri} permanent
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
These files survive across `install.sh` re-runs. The `--extra-caddyfile <path>` flag overrides the default import glob (`/etc/caddy/extra.d/*.caddy`) if needed.
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
### Register a Tunnel (from dev box)
|
### Register a Tunnel (from dev box)
|
||||||
|
|
|
||||||
|
|
@ -43,18 +43,21 @@ INSTALL_DIR="/opt/disinto-edge"
|
||||||
REGISTRY_DIR="/var/lib/disinto"
|
REGISTRY_DIR="/var/lib/disinto"
|
||||||
CADDY_VERSION="2.8.4"
|
CADDY_VERSION="2.8.4"
|
||||||
DOMAIN_SUFFIX="disinto.ai"
|
DOMAIN_SUFFIX="disinto.ai"
|
||||||
|
EXTRA_CADDYFILE="/etc/caddy/extra.d/*.caddy"
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
Usage: $0 [options]
|
Usage: $0 [options]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
--gandi-token <token> Gandi API token for wildcard cert (required)
|
--gandi-token <token> Gandi API token for wildcard cert (required)
|
||||||
--install-dir <dir> Install directory (default: /opt/disinto-edge)
|
--install-dir <dir> Install directory (default: /opt/disinto-edge)
|
||||||
--registry-dir <dir> Registry directory (default: /var/lib/disinto)
|
--registry-dir <dir> Registry directory (default: /var/lib/disinto)
|
||||||
--caddy-version <ver> Caddy version to install (default: ${CADDY_VERSION})
|
--caddy-version <ver> Caddy version to install (default: ${CADDY_VERSION})
|
||||||
--domain-suffix <suffix> Domain suffix for tunnels (default: disinto.ai)
|
--domain-suffix <suffix> Domain suffix for tunnels (default: disinto.ai)
|
||||||
-h, --help Show this help
|
--extra-caddyfile <path> Import path for operator-owned Caddy config
|
||||||
|
(default: /etc/caddy/extra.d/*.caddy)
|
||||||
|
-h, --help Show this help
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
$0 --gandi-token YOUR_GANDI_API_TOKEN
|
$0 --gandi-token YOUR_GANDI_API_TOKEN
|
||||||
|
|
@ -84,6 +87,10 @@ while [[ $# -gt 0 ]]; do
|
||||||
DOMAIN_SUFFIX="$2"
|
DOMAIN_SUFFIX="$2"
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
|
--extra-caddyfile)
|
||||||
|
EXTRA_CADDYFILE="$2"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
-h|--help)
|
-h|--help)
|
||||||
usage
|
usage
|
||||||
;;
|
;;
|
||||||
|
|
@ -229,7 +236,25 @@ chmod 600 "$GANDI_ENV"
|
||||||
# discovers the server name dynamically via _discover_server_name() so we
|
# discovers the server name dynamically via _discover_server_name() so we
|
||||||
# don't need to name the server here.
|
# don't need to name the server here.
|
||||||
CADDYFILE="/etc/caddy/Caddyfile"
|
CADDYFILE="/etc/caddy/Caddyfile"
|
||||||
cat > "$CADDYFILE" <<'CADDYEOF'
|
|
||||||
|
# Back up existing Caddyfile before overwriting
|
||||||
|
if [ -f "$CADDYFILE" ] && [ ! -f "${CADDYFILE}.pre-disinto" ]; then
|
||||||
|
cp "$CADDYFILE" "${CADDYFILE}.pre-disinto"
|
||||||
|
log_info "Backed up existing Caddyfile to ${CADDYFILE}.pre-disinto"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Create extra.d directory for operator-owned site blocks
|
||||||
|
EXTRA_DIR="/etc/caddy/extra.d"
|
||||||
|
mkdir -p "$EXTRA_DIR"
|
||||||
|
chmod 0755 "$EXTRA_DIR"
|
||||||
|
if getent group caddy >/dev/null 2>&1; then
|
||||||
|
chown root:caddy "$EXTRA_DIR"
|
||||||
|
else
|
||||||
|
log_warn "Group 'caddy' does not exist; extra.d owned by root:root"
|
||||||
|
fi
|
||||||
|
log_info "Created ${EXTRA_DIR} for operator-owned Caddy config"
|
||||||
|
|
||||||
|
cat > "$CADDYFILE" <<CADDYEOF
|
||||||
# Caddy configuration for edge control plane
|
# Caddy configuration for edge control plane
|
||||||
# Admin API enabled on 127.0.0.1:2019
|
# Admin API enabled on 127.0.0.1:2019
|
||||||
|
|
||||||
|
|
@ -243,6 +268,9 @@ cat > "$CADDYFILE" <<'CADDYEOF'
|
||||||
dns gandi {env.GANDI_API_KEY}
|
dns gandi {env.GANDI_API_KEY}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Operator-owned site blocks (apex, www, static content, etc.)
|
||||||
|
import ${EXTRA_CADDYFILE}
|
||||||
CADDYEOF
|
CADDYEOF
|
||||||
|
|
||||||
# Start Caddy
|
# Start Caddy
|
||||||
|
|
@ -362,6 +390,7 @@ echo "Configuration:"
|
||||||
echo " Install directory: ${INSTALL_DIR}"
|
echo " Install directory: ${INSTALL_DIR}"
|
||||||
echo " Registry: ${REGISTRY_FILE}"
|
echo " Registry: ${REGISTRY_FILE}"
|
||||||
echo " Caddy admin API: http://127.0.0.1:2019"
|
echo " Caddy admin API: http://127.0.0.1:2019"
|
||||||
|
echo " Operator site blocks: ${EXTRA_DIR}/ (import ${EXTRA_CADDYFILE})"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Users:"
|
echo "Users:"
|
||||||
echo " disinto-register - SSH forced command (runs ${INSTALL_DIR}/register.sh)"
|
echo " disinto-register - SSH forced command (runs ${INSTALL_DIR}/register.sh)"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue