From 2aa958e0580f4691a2c0a246d088888094087da0 Mon Sep 17 00:00:00 2001 From: Nimi Wariboko Jr Date: Sun, 3 May 2015 12:37:00 -0700 Subject: [PATCH] Update {remote} replacer to use X-Forwarded-For if its provided --- middleware/replacer.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/middleware/replacer.go b/middleware/replacer.go index 6e47d5f7..6f47dfef 100644 --- a/middleware/replacer.go +++ b/middleware/replacer.go @@ -33,6 +33,9 @@ func NewReplacer(r *http.Request, rr *responseRecorder) replacer { "{fragment}": r.URL.Fragment, "{proto}": r.Proto, "{remote}": func() string { + if fwdFor := r.Header.Get("X-Forwarded-For"); fwdFor != "" { + return fwdFor + } host, _, err := net.SplitHostPort(r.RemoteAddr) if err != nil { return r.RemoteAddr