From 0f819513e2ed60d1050664f9f5b9ddf11d404bdc Mon Sep 17 00:00:00 2001 From: Anthony Date: Fri, 27 Feb 2026 01:13:28 +0800 Subject: [PATCH] pma-gateway: allow legacy and Virtuozzo host fallback for URL generation --- scripts/pma-gateway/create_pma_gateway.sh | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/scripts/pma-gateway/create_pma_gateway.sh b/scripts/pma-gateway/create_pma_gateway.sh index eb15ec2..ea19c6a 100644 --- a/scripts/pma-gateway/create_pma_gateway.sh +++ b/scripts/pma-gateway/create_pma_gateway.sh @@ -45,12 +45,12 @@ fi # derive *.sites.mightybox.cloud as a compatibility fallback. # If a regional sites domain is seen, also derive short .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%%/*}"