From 832a2003f56cab05ff3f7e603ab8aa4e1fdf3067 Mon Sep 17 00:00:00 2001 From: milky0217 Date: Tue, 2 Jun 2026 12:16:27 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=BB=BF=E8=89=B2=E7=8E=AF=E5=A2=83(:44?= =?UTF-8?q?34)=E5=90=AF=E7=94=A8HTTPS-=E4=BB=A3=E7=A0=81=E7=A1=AC=E7=BC=96?= =?UTF-8?q?=E7=A0=81=E7=AB=AF=E5=8F=A3=E5=88=97=E8=A1=A8+=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E8=B7=AF=E5=BE=84=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/switch-env.sh | 10 +++++----- src/main.rs | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) 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) => {