Skip to content

Commit

Permalink
Log first ip from X-Forwarded-For if present
Browse files Browse the repository at this point in the history
  • Loading branch information
nicmue committed Aug 28, 2020
1 parent 94a2468 commit 90c24b9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions maintenance/log/handler.go
Expand Up @@ -66,8 +66,8 @@ func ProxyAwareRemote(r *http.Request) string {
// ip from the usual headers
for _, h := range []string{"X-Forwarded-For", "X-Real-Ip"} {
addresses := strings.Split(r.Header.Get(h), ",")
for i := len(addresses) - 1; i >= 0; i-- {
ip := strings.TrimSpace(addresses[i])
for _, address := range addresses {
ip := strings.TrimSpace(address)
realIP := net.ParseIP(ip)
if !realIP.IsGlobalUnicast() {
continue // bad address, go to next
Expand Down

0 comments on commit 90c24b9

Please sign in to comment.