diff --git a/setup.sh b/setup.sh index 769d472..026f539 100755 --- a/setup.sh +++ b/setup.sh @@ -381,7 +381,9 @@ fi # Let Caddy (user 'caddy') read the per-user public_html trees. usermod -aG "$SVC_USER" caddy 2>/dev/null || true log "writing Caddyfile" -DOMAIN_RE=$(printf '%s' "$DOMAIN" | sed 's/[.]/\\./g') # dots escaped for Caddy host_regexp +# Caddy indexes host labels from the right (com=0, profullstack=1, bbs=2, …); +# the user subdomain is the next label left, i.e. index = DOMAIN's label count. +USER_LABEL_IDX=$(printf '%s' "$DOMAIN" | awk -F. '{print NF}') cat > /etc/caddy/Caddyfile <