fixed x-forwarded-for

This commit is contained in:
2022-05-16 22:14:27 +02:00
parent 2887db2d4b
commit 2300d740d2

View File

@@ -1105,15 +1105,10 @@ func main() {
go housekeeping() go housekeeping()
r := gin.New() r := gin.New()
err = r.SetTrustedProxies([]string{"127.0.0.1", "::1"})
if err != nil {
log.Fatalf("error setting trusted proxies: %v", err)
}
r.ForwardedByClientIP = true
r.Use(gin.LoggerWithFormatter(func(param gin.LogFormatterParams) string { r.Use(gin.LoggerWithFormatter(func(param gin.LogFormatterParams) string {
return fmt.Sprintf("%s - \"%s %s %s %d %s \"%s\" %s\"\n", return fmt.Sprintf("%s - \"%s %s %s %d %s \"%s\" %s\"\n",
param.ClientIP, param.Request.Header.Get("X-Forwarded-For"),
param.Method, param.Method,
param.Path, param.Path,
param.Request.Proto, param.Request.Proto,