Ticket #3872: patch.git.diff

File patch.git.diff, 525 bytes (added by JohnMoylan, 6 years ago)

Patch to use second last IP address in list as real_ip.

  • django/middleware/http.py

    diff --git a/django/middleware/http.py b/django/middleware/http.py
    index 53b65c1..f550f57 100644
    a b class SetRemoteAddrFromForwardedFor(object): 
    5151        else:
    5252            # HTTP_X_FORWARDED_FOR can be a comma-separated list of IPs. The
    5353            # client's IP will be the first one.
    54             real_ip = real_ip.split(",")[0].strip()
     54            real_ip = real_ip.split(",")[-2].strip()
    5555            request.META['REMOTE_ADDR'] = real_ip
Back to Top