Skip to content

Commit

Permalink
fixes #4.
Browse files Browse the repository at this point in the history
  • Loading branch information
m1k1o committed Oct 30, 2022
1 parent 872e96a commit edddccb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func (Server) Init(cmd *cobra.Command) error {
return err
}

cmd.PersistentFlags().Bool("proxy", false, "allow reverse proxies")
cmd.PersistentFlags().Bool("proxy", false, "allow reverse proxies: X-Forwarded-For headers will be used to determine the client IP")
if err := viper.BindPFlag("proxy", cmd.PersistentFlags().Lookup("proxy")); err != nil {
return err
}
Expand Down
4 changes: 4 additions & 0 deletions internal/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ func New(config *config.Server) *HttpManagerCtx {
router.Use(middleware.RequestLogger(&logformatter{logger}))
router.Use(middleware.Recoverer) // Recover from panics without crashing server

if config.Proxy {
router.Use(middleware.RealIP)
}

// serve static files
if config.Static != "" {
fs := http.FileServer(http.Dir(config.Static))
Expand Down

0 comments on commit edddccb

Please sign in to comment.