Skip to content

Issue with User IP and X-Forwarded-By #46

@olaj

Description

@olaj

Not sure how to fix this but this method.

private static string IpFromXForwardedFor(HttpRequest request)
{
    var forwardedFor = request.Headers["X-Forwarded-For"];
    if (!string.IsNullOrEmpty(forwardedFor) && forwardedFor.Contains(","))
    {
        forwardedFor = forwardedFor.Split(',').Last().Trim();
    }
    return forwardedFor;
}

Didn't work well with my setup with Cloudflare. My header was like this.

X_FORWARDED_FOR: 196.215.208.37, 197.214.212.59:57956

Where the first one is the "good ip" and the second one is from Cloudflare. RollbarSharp was taking the last one and Rollbar didn't even accept that as an IP (because of the port i guess) and well it's the Cloudflare IP anyway so not that interesting. Just wanted to let you know. I run with a fork now where i take the first IP instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions