简体   繁体   English

在机架式负载均衡器后面使用自托管Web API获取客户端IP

[英]Obtaining client IP using self-hosted web API behind rackspace hosted load balancer

I have a load balanced API, using Microsoft self-hosted Web API and running over HTTPS behind a hosted Rackspace loadbalancer. 我有一个负载平衡的API,它使用Microsoft自托管的Web API并在托管的Rackspace负载均衡器后面的HTTPS上运行。 The load balancer does not terminate HTTPS but forwards the HTTPS direct to the serving host. 负载平衡器不会终止HTTPS,而是将HTTPS直接转发到服务主机。 Ie the SSL certs sit on each server handling the request. 即SSL证书位于处理请求的每台服务器上。

If I bypass the load balance I can correctly extract the client IP using request.Properties.ContainsKey(RemoteEndpointMessageProperty.Name). 如果绕过负载平衡,则可以使用request.Properties.ContainsKey(RemoteEndpointMessageProperty.Name)正确提取客户端IP。

If I go through the load balancer I don't get the client IP I get the IP of the load balancer. 如果我通过负载均衡器,则无法获取客户端IP,而无法获取负载均衡器的IP。

I have been searching and trying various methods to obtain the actual client IP to no avail. 我一直在搜索并尝试各种方法来获取实际的客户端IP都无济于事。 I have looked through the properties lists of the request whilst debugging thinking there must be a reference to the original client IP somewhere. 在调试时,我仔细查看了请求的属性列表,以为某处必须引用原始客户端IP。 Again to no avail. 再次无济于事。

There doesn't seem much I change that would help using RackSpace Web manager for the load balancer. 似乎没有太多改变可以帮助将RackSpace Web Manager用于负载均衡器。

Is it possible to extract the original client IP in this scenario, or is this information simply not there after traversing the load balancer? 在这种情况下,是否可以提取原始客户端IP,或者在遍历负载均衡器之后是否仅存在此信息?

Many Thanks in advance. 提前谢谢了。

Simon 西蒙

Using HTTPS that is not terminated by the hosted load balancer means that it cannot add anything into the encrypted stream. 使用未由托管负载均衡器终止的HTTPS意味着它无法将任何内容添加到加密流中。 This means the load balancer cannot pass on the original IP to the web server itself. 这意味着负载平衡器无法将原始IP传递给Web服务器本身。

I had the same problem with Amazon. 我在亚马逊也有同样的问题。 Check the headers it sends over, it should include the header "X-Forwarded-For" which contains the client's IP address. 检查它发送的标头,它应该包含标头“ X-Forwarded-For”,其中包含客户端的IP地址。

This might be helpful as well . 这也可能会有所帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM