Skip to content

Commit 31ef359

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents de6bdbb + 5ca0d52 commit 31ef359

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/Platforms/Exceptionless.Web/RequestInfoCollector.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public static RequestInfo Collect(HttpContextBase context, ExceptionlessConfigur
2424
};
2525

2626
try {
27-
info.ClientIpAddress = context.Request.UserHostAddress;
27+
info.ClientIpAddress = GetUserIPAddress(context);
2828
} catch (ArgumentException ex) {
2929
config.Resolver.GetLog().Error(ex, "An error occurred while setting the Client Ip Address.");
3030
}
@@ -126,5 +126,15 @@ private static Dictionary<string, string> ToDictionary(this NameValueCollection
126126

127127
return d;
128128
}
129+
130+
private static string GetUserIPAddress(HttpContextBase context)
131+
{
132+
string clientIp = context.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
133+
if (string.IsNullOrEmpty(clientIp))
134+
{
135+
clientIp = context.Request.UserHostAddress;
136+
}
137+
return clientIp;
138+
}
129139
}
130140
}

0 commit comments

Comments
 (0)