0
Fork 0
mirror of https://github.com/caddyserver/caddy.git synced 2024-12-23 22:27:38 -05:00

Update {remote} replacer to use X-Forwarded-For if its provided

This commit is contained in:
Nimi Wariboko Jr 2015-05-03 12:37:00 -07:00
parent 4a4b80450a
commit 2aa958e058

View file

@ -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