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 2020-10-11 13:59:42 -05:00
parent 3c490dbadb
commit af3122f93b
2 changed files with 8 additions and 0 deletions

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

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