top of page

General

Public·53 members

Source IP Tracking - take 2

Since we have a lot more RTUG members now, I am reposting this inquiry in hopes that someone out there has a solution.


Ever since we added a load balancer in front of our Relius Web farm, we lost the ability to track source IP addresses in the wwwtrackinglog.remote_addr field. Now, Relius always sets the remote_addr field to the IP address of our load balancer. Usually, setting the X-Forwarded-For (XFF) header is the way to solve this issue, but to our knowledge, Relius doesn't support XFF. Has anyone found a way to modify REMOTE_ADDR via JavaScript or XSL (see below for the gory details)?


As found in this Stack Overflow post, here is how to use XFF in .NET:

public string GetIPAddress()
{
    System.Web.HttpContext context = System.Web.HttpContext.Current;
    string ipAddress = context.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];

    if (!string.IsNullOrEmpty(ipAddress))
    {
        string[] addresses = ipAddress.Split(',');
        if (addresses.Length != 0)
        {
            return addresses[0];
        }
    }

    return context.Request.ServerVariables["REMOTE_ADDR"];
}
public static string GetUserIP() {   
    var ip = ( HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"] != null
          && HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"] != "" )
         ? HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]
         : HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
    if (ip.Contains( "," ))
        ip = ip.Split( ',' ).First();
    return ip.Trim();
}

@willmckamie 
15 Views
bottom of page