Add X-REAL-IP

This commit is contained in:
Daniel Mason 2021-03-28 22:09:12 +13:00
parent d2e309b699
commit 91e1e83466

View File

@ -46,10 +46,14 @@ func getUserIp(r *http.Request) net.IP {
host, _, _ := net.SplitHostPort(r.RemoteAddr) host, _, _ := net.SplitHostPort(r.RemoteAddr)
if contains(ReverseProxies, host) { if contains(ReverseProxies, host) {
forwardedFor := r.Header.Get("X-Forwarded-For") forwardedFor := r.Header.Get("X-Forwarded-For")
if forwardedFor != "" { if !contains(ReverseProxies, forwardedFor) {
host = 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) ip = net.ParseIP(host)