fix(installer): send correct Host header in Traefik routing check
The root redirect rule matches Host(`PUBLIC_HOST`), not localhost. Curl with --resolve (bash) and Host header (PS1) so the health check sends the right hostname when verifying Traefik routing. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -924,9 +924,11 @@ function Wait-DockerHealthy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function Test-Endpoint {
|
function Test-Endpoint {
|
||||||
param([string]$Name, [string]$Url, [int]$TimeoutSecs = 120)
|
param([string]$Name, [string]$Url, [int]$TimeoutSecs = 120, [string]$HostHeader = '')
|
||||||
$start = Get-Date
|
$start = Get-Date
|
||||||
$lastDot = -1
|
$lastDot = -1
|
||||||
|
$headers = @{}
|
||||||
|
if ($HostHeader) { $headers['Host'] = $HostHeader }
|
||||||
while ($true) {
|
while ($true) {
|
||||||
$elapsed = [int]((Get-Date) - $start).TotalSeconds
|
$elapsed = [int]((Get-Date) - $start).TotalSeconds
|
||||||
if ($elapsed -ge $TimeoutSecs) {
|
if ($elapsed -ge $TimeoutSecs) {
|
||||||
@@ -935,7 +937,7 @@ function Test-Endpoint {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
# -SkipCertificateCheck is PS6+ only; SSL trust is handled by Enable-TrustAllCerts above
|
# -SkipCertificateCheck is PS6+ only; SSL trust is handled by Enable-TrustAllCerts above
|
||||||
$resp = Invoke-WebRequest -Uri $Url -UseBasicParsing -TimeoutSec 5 -ErrorAction Stop
|
$resp = Invoke-WebRequest -Uri $Url -UseBasicParsing -TimeoutSec 5 -Headers $headers -ErrorAction Stop
|
||||||
$dur = [int]((Get-Date) - $start).TotalSeconds
|
$dur = [int]((Get-Date) - $start).TotalSeconds
|
||||||
Write-Host (" [ok] {0,-20} ready ({1}s)" -f $Name, $dur) -ForegroundColor Green
|
Write-Host (" [ok] {0,-20} ready ({1}s)" -f $Name, $dur) -ForegroundColor Green
|
||||||
return $true
|
return $true
|
||||||
@@ -976,7 +978,7 @@ function Verify-Health {
|
|||||||
if (-not (Test-Endpoint 'Cameleer SaaS' "https://localhost:$($c.HttpsPort)/platform/api/config" 120)) { $failed = $true }
|
if (-not (Test-Endpoint 'Cameleer SaaS' "https://localhost:$($c.HttpsPort)/platform/api/config" 120)) { $failed = $true }
|
||||||
}
|
}
|
||||||
if (-not $failed) {
|
if (-not $failed) {
|
||||||
if (-not (Test-Endpoint 'Traefik routing' "https://localhost:$($c.HttpsPort)/" 30)) { $failed = $true }
|
if (-not (Test-Endpoint 'Traefik routing' "https://localhost:$($c.HttpsPort)/" 30 $c.PublicHost)) { $failed = $true }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -885,8 +885,10 @@ wait_for_docker_healthy() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
check_endpoint() {
|
check_endpoint() {
|
||||||
local name="$1" url="$2" timeout_secs="${3:-120}"
|
local name="$1" url="$2" timeout_secs="${3:-120}" resolve="${4:-}"
|
||||||
local start_time=$(date +%s)
|
local start_time=$(date +%s)
|
||||||
|
local extra_flags=""
|
||||||
|
[ -n "$resolve" ] && extra_flags="--resolve $resolve"
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
local elapsed=$(( $(date +%s) - start_time ))
|
local elapsed=$(( $(date +%s) - start_time ))
|
||||||
@@ -894,7 +896,7 @@ check_endpoint() {
|
|||||||
printf " ${RED}[FAIL]${NC} %-20s not reachable after %ds\n" "$name" "$timeout_secs"
|
printf " ${RED}[FAIL]${NC} %-20s not reachable after %ds\n" "$name" "$timeout_secs"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
if curl -sfk -o /dev/null "$url" 2>/dev/null; then
|
if curl -sfk $extra_flags -o /dev/null "$url" 2>/dev/null; then
|
||||||
local duration=$(( $(date +%s) - start_time ))
|
local duration=$(( $(date +%s) - start_time ))
|
||||||
printf " ${GREEN}[ok]${NC} %-20s ready (%ds)\n" "$name" "$duration"
|
printf " ${GREEN}[ok]${NC} %-20s ready (%ds)\n" "$name" "$duration"
|
||||||
return 0
|
return 0
|
||||||
@@ -927,7 +929,7 @@ verify_health() {
|
|||||||
check_endpoint "Cameleer SaaS" "https://localhost:${HTTPS_PORT}/platform/api/config" 120 || failed=1
|
check_endpoint "Cameleer SaaS" "https://localhost:${HTTPS_PORT}/platform/api/config" 120 || failed=1
|
||||||
|
|
||||||
[ $failed -eq 0 ] && \
|
[ $failed -eq 0 ] && \
|
||||||
check_endpoint "Traefik routing" "https://localhost:${HTTPS_PORT}/" 30 || failed=1
|
check_endpoint "Traefik routing" "https://${PUBLIC_HOST}:${HTTPS_PORT}/" 30 "${PUBLIC_HOST}:${HTTPS_PORT}:127.0.0.1" || failed=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
|
|||||||
Reference in New Issue
Block a user