Ticket #3872: SetRemoteAddrFromForwardedFor.diff
File SetRemoteAddrFromForwardedFor.diff, 665 bytes (added by , 17 years ago) |
---|
-
django/middleware/http.py
55 55 return None 56 56 else: 57 57 # HTTP_X_FORWARDED_FOR can be a comma-separated list of IPs. 58 # Take just the first one. 59 real_ip = real_ip.split(",")[0] 58 # according to http://bob.pythonmac.org/archives/2005/09/23/apache-x-forwarded-for-caveat/ 59 # we take last element of the list 60 real_ip = real_ip.split(",")[-1].strip() 60 61 request.META['REMOTE_ADDR'] = real_ip