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:
parent
4a4b80450a
commit
2aa958e058
1 changed files with 3 additions and 0 deletions
|
@ -33,6 +33,9 @@ func NewReplacer(r *http.Request, rr *responseRecorder) replacer {
|
||||||
"{fragment}": r.URL.Fragment,
|
"{fragment}": r.URL.Fragment,
|
||||||
"{proto}": r.Proto,
|
"{proto}": r.Proto,
|
||||||
"{remote}": func() string {
|
"{remote}": func() string {
|
||||||
|
if fwdFor := r.Header.Get("X-Forwarded-For"); fwdFor != "" {
|
||||||
|
return fwdFor
|
||||||
|
}
|
||||||
host, _, err := net.SplitHostPort(r.RemoteAddr)
|
host, _, err := net.SplitHostPort(r.RemoteAddr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return r.RemoteAddr
|
return r.RemoteAddr
|
||||||
|
|
Loading…
Reference in a new issue