From 6b673017c5c5d1188f48b54a7664a20e8c873101 Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Thu, 17 Jul 2025 15:43:20 +0800 Subject: [PATCH] fix: Fix the problem of abnormal request forwarding (#9548) --- agent/middleware/certificate.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/agent/middleware/certificate.go b/agent/middleware/certificate.go index 09ee10b57..875d5d595 100644 --- a/agent/middleware/certificate.go +++ b/agent/middleware/certificate.go @@ -3,6 +3,7 @@ package middleware import ( "errors" "fmt" + "strings" "github.com/1Panel-dev/1Panel/agent/app/api/v2/helper" "github.com/1Panel-dev/1Panel/agent/global" @@ -25,9 +26,14 @@ func Certificate() gin.HandlerFunc { helper.InternalServer(c, fmt.Errorf("err certificate")) return } - masterProxyID := c.Request.Header.Get("Proxy-ID") + conn := c.Request.Header.Get("Connection") + if conn == "Upgrade" { + c.Next() + return + } + masterProxyID := c.Request.Header.Get("Proxy-Id") proxyID, err := cmd.RunDefaultWithStdoutBashC("cat /etc/1panel/.nodeProxyID") - if err == nil && len(proxyID) != 0 && proxyID != masterProxyID { + if err == nil && len(proxyID) != 0 && strings.TrimSpace(proxyID) != strings.TrimSpace(masterProxyID) { helper.InternalServer(c, fmt.Errorf("err proxy id")) return }