From 91e1e834662fc4ebe81f7b3ba876cea4f11706ea Mon Sep 17 00:00:00 2001 From: Daniel Mason Date: Sun, 28 Mar 2021 22:09:12 +1300 Subject: [PATCH] Add X-REAL-IP --- internal/goscrobble/utils.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/internal/goscrobble/utils.go b/internal/goscrobble/utils.go index b24ddb3e..7796ece6 100644 --- a/internal/goscrobble/utils.go +++ b/internal/goscrobble/utils.go @@ -46,10 +46,14 @@ func getUserIp(r *http.Request) net.IP { host, _, _ := net.SplitHostPort(r.RemoteAddr) if contains(ReverseProxies, host) { forwardedFor := r.Header.Get("X-Forwarded-For") - if forwardedFor != "" { + if !contains(ReverseProxies, forwardedFor) { host = forwardedFor + } else { + realIp := r.Header.Get("X-Real-IP") + if !contains(ReverseProxies, realIp) { + host = realIp + } } - // realIp := r.Header.Get("X-Real-IP") } ip = net.ParseIP(host)