You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# eliminate any extra addresses at the front of this list, as they could be spoofed.
43
+
ifREVERSE_PROXY_DEPTH>0:
44
+
depth=REVERSE_PROXY_DEPTH
45
+
else:
46
+
# special case for -1/negative: setting `depth` to 0 will not strip any items from the chain
47
+
depth=0
48
+
trusted_proxy_chain=full_proxy_chain[-depth:]
49
+
# accept the first (or only) address in the remaining trusted part of the chain as the actual remote address
50
+
returntrusted_proxy_chain[0].strip()
51
+
52
+
# fall back to "X-Real-Ip" if "X-Forwarded-For" isnt present
40
53
if"X-Real-Ip"inreq.headers:
41
54
returnreq.headers["X-Real-Ip"]
55
+
56
+
# if we are not proxied (or we are proxied but the headers werent present and we fell through to here), just use the remote ip addr as the true client address
0 commit comments