feat: relax tunnel proxy path restriction to allow frontend proxying
This commit is contained in:
@@ -28,14 +28,8 @@ func TravelProxyMiddleware() gin.HandlerFunc {
|
||||
return
|
||||
}
|
||||
|
||||
path := c.Request.URL.Path
|
||||
// 1.5 只拦截 API 请求,静态资源文件等必须从主节点本地加载
|
||||
if !strings.HasPrefix(path, "/api/v1/") {
|
||||
c.Next()
|
||||
return
|
||||
}
|
||||
|
||||
// 2. 白名单放行:反向隧道建立连接端点必须直达本机,不能二次代理
|
||||
path := c.Request.URL.Path
|
||||
if strings.HasPrefix(path, "/api/v1/interconnect/tunnel") {
|
||||
c.Next()
|
||||
return
|
||||
|
||||
@@ -75,12 +75,8 @@ func serveLocalProxy(session *yamux.Session) {
|
||||
return
|
||||
}
|
||||
|
||||
// 安全规则 2:严格限制只能访问本机的 /api/v1/ 接口
|
||||
if !strings.HasPrefix(r.URL.Path, "/api/v1/") {
|
||||
w.WriteHeader(http.StatusForbidden)
|
||||
w.Write([]byte("Tunnel access is strictly restricted to /api/v1/ endpoints"))
|
||||
return
|
||||
}
|
||||
// 安全规则已放宽:允许访问所有路径 (包括前端静态资源和 API),以支持主从版本不一致时的完整穿透。
|
||||
// 由 LocalEngine (Gin) 自行决定哪些接口需要认证。
|
||||
|
||||
// 确保保留 X-Tunnel-Proxy 请求头,以防后续逻辑需要判定
|
||||
r.Header.Set("X-Tunnel-Proxy", "true")
|
||||
|
||||
Reference in New Issue
Block a user