From: Tom Clegg Date: Sat, 17 Oct 2015 08:30:19 +0000 (-0400) Subject: 5824: Log actual client IP address (along with X-Forwarded-For header, if any). X-Git-Tag: 1.1.0~1259^2~20 X-Git-Url: https://git.arvados.org/arvados.git/commitdiff_plain/0f535af4fbcb7a9f6ca1e25675b31cc9656d88f3 5824: Log actual client IP address (along with X-Forwarded-For header, if any). --- diff --git a/services/keepproxy/keepproxy.go b/services/keepproxy/keepproxy.go index 24750bac44..8cfaa90458 100644 --- a/services/keepproxy/keepproxy.go +++ b/services/keepproxy/keepproxy.go @@ -198,12 +198,8 @@ func (this *ApiTokenCache) RecallToken(token string) bool { } func GetRemoteAddress(req *http.Request) string { - if realip := req.Header.Get("X-Real-IP"); realip != "" { - if forwarded := req.Header.Get("X-Forwarded-For"); forwarded != realip { - return fmt.Sprintf("%s (X-Forwarded-For %s)", realip, forwarded) - } else { - return realip - } + if xff := req.Header.Get("X-Forwarded-For"); xff != "" { + return xff + "," + req.RemoteAddr } return req.RemoteAddr }