From 32f61a0eeff8500225cac80a126eb83c4566c471 Mon Sep 17 00:00:00 2001 From: coward Date: Wed, 21 Aug 2024 11:43:57 +0800 Subject: [PATCH] =?UTF-8?q?:art:=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- http/middleware/request.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/http/middleware/request.go b/http/middleware/request.go index c90ab77..00e15e0 100644 --- a/http/middleware/request.go +++ b/http/middleware/request.go @@ -52,8 +52,8 @@ func RequestLog() gin.HandlerFunc { method := c.Request.Method // 请求方式 ip := c.ClientIP() // 取出IP // 处理实际客户端IP - if c.Request.Header.Get("X-Real-IP") != "" { - ip = c.Request.Header.Get("X-Real-IP") // 这个是网关Nginx自定义的Header头 + if c.Request.Header.Get("X-Real-Ip") != "" { + ip = c.Request.Header.Get("X-Real-Ip") // 这个是网关Nginx自定义的Header头 } else if c.Request.Header.Get("X-Forwarded-For") != "" { ip = c.Request.Header.Get("X-Forwarded-For") // 这个是网关Nginx自定义的Header头 }