fix: 绿色环境(:4434)启用HTTPS-代码硬编码端口列表+配置路径修正
This commit is contained in:
@@ -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 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 $blue_ok"
|
||||||
echo " 绿色健康: HTTP $green_ok"
|
echo " 绿色健康: HTTP $green_ok"
|
||||||
echo ""
|
echo ""
|
||||||
@@ -94,8 +94,8 @@ switch_to() {
|
|||||||
|
|
||||||
# 先验证目标环境健康
|
# 先验证目标环境健康
|
||||||
echo "验证目标环境健康..."
|
echo "验证目标环境健康..."
|
||||||
local proto="http"; [ "$target_port" = "4433" ] && proto="https"
|
local proto="https"
|
||||||
local extra=""; [ "$proto" = "https" ] && extra="-k"
|
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")
|
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
|
if [ "$target_ok" != "200" ]; then
|
||||||
error "目标环境 :${target_port} 健康检查失败 (HTTP $target_ok),取消切换"
|
error "目标环境 :${target_port} 健康检查失败 (HTTP $target_ok),取消切换"
|
||||||
@@ -103,8 +103,8 @@ switch_to() {
|
|||||||
fi
|
fi
|
||||||
info "目标环境健康 ✅"
|
info "目标环境健康 ✅"
|
||||||
|
|
||||||
# 修改 proxy_pass(根据端口自动选择 http/https)
|
# 修改 proxy_pass(两个端口都是 HTTPS)
|
||||||
local target_proto="http"; [ "$target_port" = "4433" ] && target_proto="https"
|
local target_proto="https"
|
||||||
info "修改 OpenResty proxy_pass → ${target_proto}://127.0.0.1:${target_port}..."
|
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 || {
|
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 失败"
|
error "修改 proxy_pass 失败"
|
||||||
|
|||||||
@@ -302,7 +302,7 @@ async fn main() -> std::io::Result<()> {
|
|||||||
let http_client_clone = http_client.clone();
|
let http_client_clone = http_client.clone();
|
||||||
let app_state_clone = app_state.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() {
|
let ssl_builder = match create_ssl_acceptor() {
|
||||||
Ok(builder) => builder,
|
Ok(builder) => builder,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user