Add "behind proxy" mode to use forwarded IP headers

This commit is contained in:
William Bouzourène 2025-01-26 14:24:55 +01:00
parent 272ccc1929
commit a6e05ba4c4
3 changed files with 11 additions and 2 deletions

11
main.go
View file

@ -67,10 +67,17 @@ func main() {
pongo2.RegisterFilter("time_diff", helpers.TemplTimeDiff)
app := fiber.New(fiber.Config{
fiberConfig := fiber.Config{
Views: engine,
ErrorHandler: helpers.FiberErrorHandler,
})
}
// If app behind proxy, use headers for IP
if config.App.BehindProxy {
fiberConfig.ProxyHeader = fiber.HeaderXForwardedFor
}
app := fiber.New(fiberConfig)
if config.DevMode {
app.Static("/static", "./static")