连接 URL 时可以指定 IP 吗?
我在 www.someurl.com 上有一个负载均衡器,解析为 100.100.100.100。有两台服务器处于平衡状态:100.100.100.101 和 100.100.100.102。这是为了创建健康检查,以确保平衡站点都处于活动状态。
有什么方法可以连接到主机 www.someurl.com 但指定我想要实际连接到的 IP?我正在 C# 中实现这个解决方案,并研究了使用 HttpWebRequest 和套接字。
I have a load balancer sitting on www.someurl.com, resolving to 100.100.100.100. There are two servers being balanced: 100.100.100.101 and 100.100.100.102. This is in order to create a health check which will make sure that the balanced sites are both alive.
Is there any way I can connect to the host www.someurl.com but specify which IP I want to actually connect to? I am implementing this solution in C# and have looked into using HttpWebRequest and also Sockets.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我使用了两种方法来完成此任务。首先,您可以使用主机文件将域名映射到 .101 或 .102。或者,您可以创建映射到每个服务器的新 dns 整体(www1.someurl.com 和 www2.someurl.com)。
如果您需要有关这两种方法的更多详细信息,请告诉我。
I have used two methods to accomplish this. First, you can use your hosts file to map the domain name to .101 or .102. Or, you can create new dns entires (www1.someurl.com and www2.someurl.com) that map to each server.
Let me know if you need more detail on either of these methods.
如果这些 IP 地址可从客户端公开访问,那么可以,您可以直接指定 IP (
var request = WebRequest.Create("http://100.100.100.101");
)。但我怀疑这不是你的情况。从发送请求的位置无法直接看到 IP 地址,只能看到负载均衡器。当然,在这种情况下,您只能向该负载均衡器发送请求。If those IP addresses are publicly accessible from the client, then yes, you can directly specify the IP (
var request = WebRequest.Create("http://100.100.100.101");
). But I suspect that this is not your case. The IP addresses are not directly visible from where you are sending the request, only the load balancer is. In this case you can only send a request to this load balancer of course.