pma-gateway: allow legacy and Virtuozzo host fallback for URL generation

main
Anthony 2026-02-27 01:13:28 +08:00
parent 5098565f99
commit 0f819513e2
1 changed files with 10 additions and 5 deletions

View File

@ -45,12 +45,12 @@ fi
# derive *.sites.mightybox.cloud as a compatibility fallback.
# If a regional sites domain is seen, also derive short <site>.mightybox.cloud
# as preferred public URL host candidate.
HOSTNAME_DOMAIN=$(hostname -f)
HOSTNAME_DOMAIN=${HOSTNAME_DOMAIN#node*-}
HOSTNAME_FQDN=$(hostname -f)
HOSTNAME_DOMAIN=${HOSTNAME_FQDN#node*-}
DOMAIN_CANDIDATES=()
SEEN_DOMAINS="|"
for candidate in "$CERT_DOMAIN" "${JELASTIC_ENV_DOMAIN:-}" "$HOSTNAME_DOMAIN"; do
for candidate in "$CERT_DOMAIN" "${JELASTIC_ENV_DOMAIN:-}" "$HOSTNAME_FQDN" "$HOSTNAME_DOMAIN"; do
# Normalize host-like input (strip scheme/path/port if present).
candidate="${candidate#https://}"
candidate="${candidate#http://}"
@ -83,6 +83,10 @@ for candidate in "$CERT_DOMAIN" "${JELASTIC_ENV_DOMAIN:-}" "$HOSTNAME_DOMAIN"; d
fi
done
# Preserve original host candidates (including legacy Virtuozzo domains)
# for URL-host fallback probing only.
URL_FALLBACK_DOMAIN_CANDIDATES=("${DOMAIN_CANDIDATES[@]}")
# Never use legacy *.sites.mightybox.dev domains for PMA gateway certificates.
FILTERED_DOMAINS=()
for candidate in "${DOMAIN_CANDIDATES[@]}"; do
@ -557,11 +561,12 @@ if [[ "$URL_HOST" =~ ^(.+):[0-9]+$ ]]; then
fi
# Best-effort fallback: if preferred host is not reachable on 8443,
# try other known domain candidates before printing final gateway URL.
# try other known domain candidates (including preserved legacy/original
# Virtuozzo URL hosts for link fallback only) before printing final URL.
if command -v timeout >/dev/null 2>&1; then
URL_HOST_CANDIDATES=()
URL_HOST_SEEN="|"
for candidate in "$URL_HOST" "$ENV_HOST" "${DOMAIN_CANDIDATES[@]}"; do
for candidate in "$URL_HOST" "$ENV_HOST" "${DOMAIN_CANDIDATES[@]}" "${URL_FALLBACK_DOMAIN_CANDIDATES[@]}"; do
candidate="${candidate#https://}"
candidate="${candidate#http://}"
candidate="${candidate%%/*}"