fix: 绿色环境(:4434)启用HTTPS-代码硬编码端口列表+配置路径修正

This commit is contained in:
2026-06-02 12:16:27 +08:00
parent f8da9ff8f7
commit 832a2003f5
2 changed files with 6 additions and 6 deletions

View File

@@ -69,7 +69,7 @@ show_status() {
# 检查两个端口是否可达
local blue_ok; blue_ok=$(ssh "$SSH_HOST" "curl -s -o /dev/null -w '%{http_code}' --max-time 3 https://127.0.0.1:4433/health -k" 2>/dev/null || echo "000")
local green_ok; green_ok=$(ssh "$SSH_HOST" "curl -s -o /dev/null -w '%{http_code}' --max-time 3 http://127.0.0.1:4434/health" 2>/dev/null || echo "000")
local green_ok; green_ok=$(ssh "$SSH_HOST" "curl -s -o /dev/null -w '%{http_code}' --max-time 3 https://127.0.0.1:4434/health -k" 2>/dev/null || echo "000")
echo " 蓝色健康: HTTP $blue_ok"
echo " 绿色健康: HTTP $green_ok"
echo ""
@@ -94,8 +94,8 @@ switch_to() {
# 先验证目标环境健康
echo "验证目标环境健康..."
local proto="http"; [ "$target_port" = "4433" ] && proto="https"
local extra=""; [ "$proto" = "https" ] && extra="-k"
local proto="https"
local extra="-k"
local target_ok; target_ok=$(ssh "$SSH_HOST" "curl -s -o /dev/null -w '%{http_code}' --max-time 3 ${proto}://127.0.0.1:${target_port}/health ${extra}" 2>/dev/null || echo "000")
if [ "$target_ok" != "200" ]; then
error "目标环境 :${target_port} 健康检查失败 (HTTP $target_ok),取消切换"
@@ -103,8 +103,8 @@ switch_to() {
fi
info "目标环境健康 ✅"
# 修改 proxy_pass根据端口自动选择 http/https
local target_proto="http"; [ "$target_port" = "4433" ] && target_proto="https"
# 修改 proxy_pass两个端口都是 HTTPS
local target_proto="https"
info "修改 OpenResty proxy_pass → ${target_proto}://127.0.0.1:${target_port}..."
ssh "$SSH_HOST" "docker exec ${NGINX_CONTAINER} sh -c \"sed -i 's|proxy_pass https\?://127.0.0.1:[0-9]*|proxy_pass ${target_proto}://127.0.0.1:${target_port}|' ${ROOT_CONF}\"" 2>&1 || {
error "修改 proxy_pass 失败"