diff --git a/scripts/switch-env.sh b/scripts/switch-env.sh index a33cdd2..20c5430 100755 --- a/scripts/switch-env.sh +++ b/scripts/switch-env.sh @@ -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 失败" diff --git a/src/main.rs b/src/main.rs index b10f079..99a02c6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -302,7 +302,7 @@ async fn main() -> std::io::Result<()> { let http_client_clone = http_client.clone(); let app_state_clone = app_state.clone(); - if *port == 443 || *port == 8443 || *port == 4433 { + if *port == 443 || *port == 8443 || *port == 4433 || *port == 4434 { let ssl_builder = match create_ssl_acceptor() { Ok(builder) => builder, Err(e) => {