在使用负载均衡的情况下,通过 context.Connection.RemoteIpAddress 获取到的是负载均衡的 IP 地址,需要通过 X-Forwarded-For 请求头才能获取到客户端的真实 IP . 之前采用的方式是自己直接获取 X-Forwarded-For 请求头,代码如下: public static class HttpContextExtensions { public static string GetUserIp(this HttpContext context)…
翻译自 https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/linux-nginx?view=aspnetcore-5.0 本文介绍了在 Ubuntu 16.04 服务器上设置生产环境可用的 ASP.NET Core 环境.这里的介绍对于更新版本的 Ubuntu 可能也会工作,但是并没有在更新版本的服务器上测试. 更过关于 ASP.NET Core 只是的 Linux 发行版,请查看 Prerequisites for .NE…
https://docs.microsoft.com/en-us/aspnet/core/fundamentals/servers/kestrel?tabs=aspnetcore1x&view=aspnetcore-2.2 By Tom Dykstra, Chris Ross, and Stephen Halter Kestrel is a cross-platform web server for ASP.NET Core. Kestrel is the web server that's i…