fix: Fix the problem of abnormal request forwarding (#9548)

This commit is contained in:
ssongliu 2025-07-17 15:43:20 +08:00 committed by GitHub
parent e66bd43fc6
commit 6b673017c5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -3,6 +3,7 @@ package middleware
import ( import (
"errors" "errors"
"fmt" "fmt"
"strings"
"github.com/1Panel-dev/1Panel/agent/app/api/v2/helper" "github.com/1Panel-dev/1Panel/agent/app/api/v2/helper"
"github.com/1Panel-dev/1Panel/agent/global" "github.com/1Panel-dev/1Panel/agent/global"
@ -25,9 +26,14 @@ func Certificate() gin.HandlerFunc {
helper.InternalServer(c, fmt.Errorf("err certificate")) helper.InternalServer(c, fmt.Errorf("err certificate"))
return 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") 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")) helper.InternalServer(c, fmt.Errorf("err proxy id"))
return return
} }