Skip to content

Commit 70181a3

Browse files
davidfischeragjohnson
authored andcommitted
Handle ports in X Forwarded For (#4539)
1 parent 43c07a9 commit 70181a3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

readthedocs/analytics/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def get_client_ip(request):
2626
# Get the original IP address (eg. "X-Forwarded-For: client, proxy1, proxy2")
2727
x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR', '').split(',')[0]
2828
if x_forwarded_for:
29-
ip_address = x_forwarded_for
29+
ip_address = x_forwarded_for.rsplit(':')[0]
3030

3131
return ip_address
3232

0 commit comments

Comments
 (0)