views:

233

answers:

1

My ASP.NET application checks the IP of the calling client.

But I have to host it behind a Linux-Box where Apache redirects it to an internal Windows 2003 Server running IIS like:

ProxyPass /srs http://192.168.21.15/srs/

where 192.168.21.15 is the internal IP of the Windows-server, and 192.168.21.1 the internal IP of the Linux box that gets the request from the internet.

Now, it seems to me that requests from the intERnet that are forwarded to w.x.y.15 all seem to origin from w.x.y.1

How can I preserve (or forward) the original IP?

I heard about X-forwarded-for... but how do I retrieve this value in C# ??

Thank you, Reinhard

+1  A: 

In general if a proxy server modifies the IP address information the original IP address is stored in the HTTP_X_FORWARDED_FOR server variable. To access this in ASP.NET using C# you can use:

Request.ServerVariables["HTTP_X_FORWARDED_FOR"]
Ari