fix(router): use CIDR to trust all proxies for Host header validation
Build and Deploy / build-and-push (push) Successful in 53s
Build and Deploy / build-and-push (push) Successful in 53s
This commit is contained in:
@@ -45,8 +45,9 @@ func Setup(c *Controllers) *gin.Engine {
|
||||
router := gin.New()
|
||||
|
||||
// 信任所有反向代理(Docker/Nginx 场景)
|
||||
// 设置为 nil 表示信任所有,避免 "invalid Host header" 错误
|
||||
router.SetTrustedProxies(nil)
|
||||
// 使用 CIDR "0.0.0.0/0" 信任所有 IPv4,"::/0" 信任所有 IPv6
|
||||
// 避免 "Forbidden: invalid Host header" 错误
|
||||
router.SetTrustedProxies([]string{"0.0.0.0/0", "::/0"})
|
||||
|
||||
router.Use(middleware.GinLogger(), middleware.GinRecovery())
|
||||
router.Use(middleware.TravelProxyMiddleware())
|
||||
|
||||
Reference in New Issue
Block a user