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头 }