1.nuget 引用 Microsoft.AspNetCore.HttpOverrides
2.app.UseForwardedHeaders(new ForwardedHeadersOptions { ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto });
3.使用
var ip = HttpContext.Connection.RemoteIpAddress;//ip地址
var port = HttpContext.Connection.RemotePort;//端口