Closed
Description
Friends, the update to 1.7 broke the work with IP addresses of clients.
I am proxying Go through Nginx
location /backend/ {
rewrite /backend/(.*) /$1 break;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://127.0.0.1:8080;
}
I read this #2693
But I don't understand what to write in router.TrustedProxies
func GinRouter() *gin.Engine {
router := gin.New()
// Set a lower memory limit for multipart forms
router.MaxMultipartMemory = 100 << 20 // 100 MB
// Custom Logger
router.Use(gin.LoggerWithFormatter(func(param gin.LogFormatterParams) string {
return fmt.Sprintf("%s |%s %d %s| %s |%s %s %s %s | %s | Body: %s | %s | %s\n",
param.TimeStamp.Format(time.RFC1123),
param.StatusCodeColor(),
param.StatusCode,
param.ResetColor(),
param.ClientIP,
param.MethodColor(),
param.Method,
param.ResetColor(),
param.Path,
param.Latency,
byteCountSI(param.BodySize),
param.Request.UserAgent(),
param.ErrorMessage,
)
}))
// Recovery middleware recovers from any panics and writes a 500 if there was one.
router.Use(gin.Recovery())
return router
}
Thanks everyone 🙏🏻
Metadata
Metadata
Assignees
Labels
No labels