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.
60
-
ifsettings.REVERSE_PROXY_DEPTH>0:
61
-
depth=settings.REVERSE_PROXY_DEPTH
62
-
else:
63
-
# special case for -1/negative: setting `depth` to 0 will not strip any items from the chain
64
-
depth=0
65
-
trusted_proxy_chain=full_proxy_chain[-depth:]
66
-
# accept the first (or only) address in the remaining trusted part of the chain as the actual remote address
67
-
returntrusted_proxy_chain[0].strip()
68
-
69
-
# fall back to "X-Real-Ip" if "X-Forwarded-For" isnt present
70
-
x_real_ip=req.META.get("HTTP_X_REAL_IP")
71
-
ifx_real_ip:
72
-
returnx_real_ip
73
-
74
-
# 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
# eliminate any extra addresses at the front of this list, as they could be spoofed.
696
-
ifsettings.REVERSE_PROXY_DEPTH>0:
697
-
depth=settings.REVERSE_PROXY_DEPTH
698
-
else:
699
-
# special case for -1/negative: setting `depth` to 0 will not strip any items from the chain
700
-
depth=0
701
-
trusted_proxy_chain=full_proxy_chain[-depth:]
702
-
# accept the first (or only) address in the remaining trusted part of the chain as the actual remote address
703
-
returntrusted_proxy_chain[0].strip()
704
-
705
-
# fall back to "X-Real-Ip" if "X-Forwarded-For" isnt present
706
-
x_real_ip=req.META.get("HTTP_X_REAL_IP")
707
-
ifx_real_ip:
708
-
returnx_real_ip
709
-
710
-
# 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