Skip to content

Commit 079e92b

Browse files
committed
add possibility to set trusted proxies
rel #200
1 parent a5dbf8a commit 079e92b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/webserver.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,14 @@ func runWebServer() {
6363
c.JSON(http.StatusNotFound, gin.H{"code": "PAGE_NOT_FOUND", "message": "Page not found"})
6464
})
6565

66-
// disable proxy feature of gin
67-
_ = router.SetTrustedProxies(nil)
66+
// Set proxy feature of gin
67+
trustedProxies := getEnv("GIN_TRUSTED_PROXIES", "")
68+
if len(trustedProxies) > 0 {
69+
_ = router.SetTrustedProxies(strings.Split(trustedProxies, ","))
70+
log.Print(strings.Split(trustedProxies, ","))
71+
} else {
72+
_ = router.SetTrustedProxies(nil)
73+
}
6874

6975
// Ping-endpoint
7076
router.GET("/ping", func(c *gin.Context) {

0 commit comments

Comments
 (0)