[英]ASP.Net Core Detect real client IP
I've got an ASP.NET Core app hosting on IIS, the server with which is behind the router. 我在IIS上托管了一个ASP.NET Core应用程序,该服务器位于路由器后面。 I need to detect real clients IPs.
我需要检测真实的客户端IP。 From the local network
context.HttpContext.Connection.RemoteIpAddress
returns correct IP, but from the outside it is always 127.0.0.1
. 从本地网络
context.HttpContext.Connection.RemoteIpAddress
返回正确的IP,但从外部始终为127.0.0.1
。
Also I tried to look at X-Original-For
header which locally gives 127.0.0.1
and nothing form the outside. 我还尝试查看
X-Original-For
标头,它在本地提供127.0.0.1
,而外部没有任何形式。
I tried UseForwardedHeaders
( https://stackoverflow.com/a/41450563/4801505 ) middleware but as I got it the middleware is already used by UseIISIntegration
( https://github.com/aspnet/Docs/issues/2384 ) so there is no sense using it twice. 我尝试了
UseForwardedHeaders
( https://stackoverflow.com/a/41450563/4801505 )中间件,但据我UseIISIntegration
,中间件已被UseIISIntegration
( https://github.com/aspnet/Docs/issues/2384 )使用。两次使用是没有意义的。
So, can I achieve the thing at all in my circumstances? 那么,在我所处的环境中,我能完全实现目标吗? Maybe some IIS config required?
也许需要一些IIS配置?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.