Browse Source

Adds support for X-Forwarded-For and X-Real-IP headers so that the correct IP address shows up in the logs.

Fixes #1999
pull/2060/head
Jordan Wright 8 months ago
parent
commit
af3122f93b
2 changed files with 8 additions and 0 deletions
  1. +4
    -0
      controllers/phish.go
  2. +4
    -0
      controllers/route.go

+ 4
- 0
controllers/phish.go View File

@ -121,6 +121,10 @@ func (ps *PhishingServer) registerRoutes() {
gzipWrapper, _ := gziphandler.NewGzipLevelHandler(gzip.BestCompression)
phishHandler := gzipWrapper(router)
// Respect X-Forwarded-For and X-Real-IP headers in case we're behind a
// reverse proxy.
phishHandler = handlers.ProxyHeaders(phishHandler)
// Setup logging
phishHandler = handlers.CombinedLoggingHandler(log.Writer(), phishHandler)
ps.server.Handler = phishHandler

+ 4
- 0
controllers/route.go View File

@ -161,6 +161,10 @@ func (as *AdminServer) registerRoutes() {
gzipWrapper, _ := gziphandler.NewGzipLevelHandler(gzip.BestCompression)
adminHandler = gzipWrapper(adminHandler)
// Respect X-Forwarded-For and X-Real-IP headers in case we're behind a
// reverse proxy.
adminHandler = handlers.ProxyHeaders(adminHandler)
// Setup logging
adminHandler = handlers.CombinedLoggingHandler(log.Writer(), adminHandler)
as.server.Handler = adminHandler

Loading…
Cancel
Save