获取IIS服务器变量的客户端值负载平衡环境 [英] Getting client values of IIS Server Variables in Load Balanced Environment

查看:181
本文介绍了获取IIS服务器变量的客户端值负载平衡环境的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个的联网的中,我需要得到客户机的IP ASP.NET Web应用程序。我这样做,可见以下code:

I have an intranet ASP.NET web application in which I need to get the IP of the client's machine. I do this vis the following code:

HttpContext.Current.Request.ServerVariables.Item("REMOTE_HOST")

它使用时,我的ASP.NET站点一台服务器上只托管工作。然而,一旦我们得到了安装负载平衡器和迁移我们的应用程序到Web场中,code以上返回的负载均衡的设备的IP,而不是客户端了。

It used to work when my ASP.NET site was only hosted on a single server. However once we got the load balancer installed and migrated our apps to a web farm, the code above returns the IP of the Load Balancer device and not of the client anymore.

我对网络乡亲的工作,以确定哪些可以用不同的负载平衡器配置,但在此期间,我想知道是否有另一种方式,我可以得到比使用IIS服务器变量客户端的IP等?或任何其他建议?

I am working with the networking folks to determine what can be configured differently with the load balancer, but in the meantime I was wondering if there was another way I could get the client's IP other than using that IIS Server Variable? Or any other suggestions?

感谢您!

推荐答案

哪些负载平衡器您使用的?这听起来就好像你的负载平衡器充当网络通信的代理,因此有理由源似乎来自LB.大多数硬件负载均衡是建立在Linux平台上并没有规定的透明度,如果内核支持的话:
http://www.mjmwired.net/kernel/Documentation/networking/tproxy.txt
然而,这很可能需要到单位和部分停工的root访问权限。但它是什么,可能是值得一提的供应商的支持团队,如果他们没有任何想法。

Which load balancer are you using? It sounds as if your load balancer is acting as a proxy for the web traffic, hence the reason the source appears to come from the LB. Most hardware load balancers are built on Linux platforms and there is provision for transparency if the kernel supports it: http://www.mjmwired.net/kernel/Documentation/networking/tproxy.txt However, this would probably require root access to the unit and some downtime. But it is something that may be worth mentioning to the vendor's support team if they don't have any ideas.

另外一个(希望更容易)选项:您可以配置负载均衡的代理编写客户端的源IP在HTTP的X转发换头:
http://en.wikipedia.org/wiki/X-Forwarded-For
然后你就可以用类似的方法来读取通过ASP.net这个头:

Another (hopefully much easier) option: You may be able to configure the load balancer's proxy to write the client's source IP in the HTTP x-forwarded-for header: http://en.wikipedia.org/wiki/X-Forwarded-For And then you'll be able to read this header via ASP.net in a similar way:

Request.ServerVariables("X-Forwarded-For")

这可能已经工作,如果代理已经这样做了。

This may already work if the proxy is already doing this.

真的是你的选择取决于你的负载平衡器能够,什么是可配置的。注意在上面的维基页面的底部常见的硬件供应商的名单。

Really your options depend on what your load balancer is capable of, and what is configurable. Note the list of common hardware vendors at the bottom of the wiki page above.

这篇关于获取IIS服务器变量的客户端值负载平衡环境的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆