diff --git a/admin/api/handlers.go b/admin/api/handlers.go index b41bbcd2..228970bd 100644 --- a/admin/api/handlers.go +++ b/admin/api/handlers.go @@ -19,7 +19,10 @@ type DispatchFunction func(httprouter.Params, []byte) (interface{}, error) func apiHandler(f DispatchFunction) func(http.ResponseWriter, *http.Request, httprouter.Params) { return func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) { - log.Printf("Handling %s request from %s: %s [%s]\n", r.Method, r.RemoteAddr, r.URL.Path, r.UserAgent()) + if addr := r.Header.Get("X-Forwarded-For"); addr != "" { + r.RemoteAddr = addr + } + log.Printf("%s \"%s %s\" [%s]\n", r.RemoteAddr, r.Method, r.URL.Path, r.UserAgent()) w.Header().Set("Content-Type", "application/json") diff --git a/frontend/resolution.go b/frontend/resolution.go index 34e9fd00..b50a9307 100644 --- a/frontend/resolution.go +++ b/frontend/resolution.go @@ -24,13 +24,17 @@ const resolutiontpl = ` ` func (s ResolutionHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { + if addr := r.Header.Get("X-Forwarded-For"); addr != "" { + r.RemoteAddr = addr + } + if !enableResolutionRoute { log.Printf("UNHANDELED %s request from %s: /resolution%s [%s]\n", r.Method, r.RemoteAddr, r.URL.Path, r.UserAgent()) http.NotFound(w, r) return } - log.Printf("Handling %s request from %s: /resolution%s [%s]\n", r.Method, r.RemoteAddr, r.URL.Path, r.UserAgent()) + log.Printf("%s \"%s /resolution%s\" [%s]\n", r.RemoteAddr, r.Method, r.URL.Path, r.UserAgent()) w.Header().Set("Content-Type", "text/html") diff --git a/frontend/submissions.go b/frontend/submissions.go index 9ee2a74a..0e7d8106 100644 --- a/frontend/submissions.go +++ b/frontend/submissions.go @@ -24,7 +24,10 @@ type submissionTeamChecker struct{ } func (c submissionChecker) ServeHTTP(w http.ResponseWriter, r *http.Request) { - log.Printf("Handling %s %s request from %s: %s [%s]\n", r.Method, c.kind, r.RemoteAddr, r.URL.Path, r.UserAgent()) + if addr := r.Header.Get("X-Forwarded-For"); addr != "" { + r.RemoteAddr = addr + } + log.Printf("%s \"%s %s\" => %s [%s]\n", r.RemoteAddr, r.Method, r.URL.Path, c.kind, r.UserAgent()) w.Header().Set("Content-Type", "application/json") diff --git a/frontend/time/time.go b/frontend/time/time.go index a044eea2..aa41fdaf 100644 --- a/frontend/time/time.go +++ b/frontend/time/time.go @@ -20,7 +20,10 @@ type timeObject struct { } func (t TimeHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { - log.Printf("Handling %s request from %s: %s [%s]\n", r.Method, r.RemoteAddr, r.URL.Path, r.UserAgent()) + if addr := r.Header.Get("X-Forwarded-For"); addr != "" { + r.RemoteAddr = addr + } + log.Printf("%s \"%s %s\" [%s]\n", r.RemoteAddr, r.Method, r.URL.Path, r.UserAgent()) w.Header().Set("Content-Type", "application/json")