1 2 3 4 5 6 7 8 9 10 11 | def get_ip(request):
"""Returns the IP of the request, accounting for the possibility of being
behind a proxy.
"""
ip = request.META.get("HTTP_X_FORWARDED_FOR", None)
if ip:
# X_FORWARDED_FOR returns client1, proxy1, proxy2,...
ip = ip.split(", ")[0]
else:
ip = request.META.get("REMOTE_ADDR", "")
return ip
|
More like this
- Add get_addr() method to request object by nikmolnar 5 months, 1 week ago
- Effective content caching for mass-load site using redirect feature by nnseva 1 year, 10 months ago
- Single Django App behind multiple Apache Proxies by chadmaine 6 years ago
- Enable AWS ELB with SSL Termination by zvikico 1 year, 11 months ago
- Semi-Portable recaptcha integration with django forms by pinkeen 2 years, 5 months ago
Comments