简体   繁体   English

从Windows Azure服务获取客户端IP地址

[英]Acquire client IP address from Windows Azure service

We have a couple of web services built with service stack and deployed as self-hosted executables to several Windows Azure servers. 我们有几个使用服务堆栈构建的Web服务,并作为自托管可执行文件部署到多个Windows Azure服务器。 This setup was migrated from Amazon EC2. 此设置已从Amazon EC2迁移。

The problem we're facing is that the services make heavy use of ip address geo-resolution (ie map IP address to country / region). 我们面临的问题是服务大量使用了IP地址的地理分辨率(即将IP地址映射到国家/地区)。 However under the Azure setup, all requests appear to originate from the server's own external IP, which is a LAN IP. 但是,在Azure设置下,所有请求似乎都源自服务器自身的外部IP,即LAN IP。

For example if the Virtual Machine's ip address is 10.0.0.4, all HTTP appears to originate from 10.0.0.4. 例如,如果虚拟机的IP地址是10.0.0.4,则所有HTTP似乎都源自10.0.0.4。

There are tons of settings and features which use different terminology to Amazon. 有许多设置和功能使用与Amazon不同的术语。 We've tried looking into several things (such as direct server return), but so far we've come up short. 我们已经尝试调查了几件事(例如直接服务器返回),但是到目前为止,我们已经简短了。

What is the correct way to achieve the simplest "port forwarding" such that the service port is directly open and requests appear to originate from their actual origin? 什么是实现最简单的“端口转发”以使服务端口直接打开并且请求似乎源自其实际来源的正确方法?

I've un-deleted the question and answering it because it turns out it is a small ServiceStack gotcha after all, and might help someone else in the future: 我还没有删除问题并回答,因为事实证明这毕竟是一个很小的ServiceStack陷阱,并且将来可能会帮助其他人:

Don't use UserHostAddress , use RemoteIp instead. 不要使用UserHostAddress ,而应使用RemoteIp

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

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