Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collect the user IP from X-Forwarded-For, then falls back to X-Real-Ip #370

Merged
merged 2 commits into from
Apr 6, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions rollbar/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1605,13 +1605,12 @@ def _parse_response(path, access_token, params, resp, endpoint=None):


def _extract_user_ip(request):
# some common things passed by load balancers... will need more of these.
real_ip = request.headers.get('X-Real-Ip')
if real_ip:
return real_ip
forwarded_for = request.headers.get('X-Forwarded-For')
if forwarded_for:
return forwarded_for
real_ip = request.headers.get('X-Real-Ip')
if real_ip:
return real_ip
return request.remote_addr


Expand Down