fixed x-forwarded-for
This commit is contained in:
7
main.go
7
main.go
@@ -1105,15 +1105,10 @@ func main() {
|
||||
go housekeeping()
|
||||
|
||||
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 {
|
||||
return fmt.Sprintf("%s - \"%s %s %s %d %s \"%s\" %s\"\n",
|
||||
param.ClientIP,
|
||||
param.Request.Header.Get("X-Forwarded-For"),
|
||||
param.Method,
|
||||
param.Path,
|
||||
param.Request.Proto,
|
||||
|
Reference in New Issue
Block a user