asp.net
core The program is deployed incentos7( The following solution, Other systems can be used, It's just my own deploymentcentos7), Use serverjexus Deployment,AppHost Pattern.

Because the request was made byjexus Forwarded, thereforeasp.net zero Acquiredip Always be127.0.0.1..

Solution:

Use fromJexus Provided by the author's cloudJwsIntegration replaceIISIntegration, It changes the default to get from the request headerip Rules, Instead of
“X-Original-For” Get remoteip( Tested Use"X-Real-IP" Can also get).

JwsIntegration.cs:
/// <summary> /// For handling customersIP address, PortHostBuilder middleware /// </summary> public static
class WebHostBuilderJexusExtensions { /// <summary> /// EnableJexusIntegration middleware
/// </summary> /// <param name="hostBuilder"></param> /// <returns></returns>
public static IWebHostBuilder UseJexusIntegration(this IWebHostBuilder
hostBuilder) { if (hostBuilder == null) { throw new
ArgumentNullException(nameof(hostBuilder)); } // Check if it has been loaded if
(hostBuilder.GetSetting(nameof(UseJexusIntegration)) != null) { return
hostBuilder; } // Set loaded Tags, Prevent duplicate loading
hostBuilder.UseSetting(nameof(UseJexusIntegration), true.ToString()); //
Add toconfigure Handle hostBuilder.ConfigureServices(services => {
services.AddSingleton<IStartupFilter>(new JwsSetupFilter()); }); return
hostBuilder; } } class JwsSetupFilter : IStartupFilter { public
Action<IApplicationBuilder> Configure(Action<IApplicationBuilder> next) {
return app => { app.UseMiddleware<JexusMiddleware>(); next(app); }; } } class
JexusMiddleware { readonly RequestDelegate _next; public
JexusMiddleware(RequestDelegate next, ILoggerFactory loggerFactory,
IOptions<IISOptions> options) { _next = next; } public async Task
Invoke(HttpContext httpContext) { var headers = httpContext.Request.Headers;
try { if (headers != null && headers.ContainsKey("X-Original-For")) { var
ipaddAdndPort = headers["X-Original-For"].ToArray()[0]; var dot =
ipaddAdndPort.IndexOf(":", StringComparison.Ordinal); var ip = ipaddAdndPort;
var port = 0; if (dot > 0) { ip = ipaddAdndPort.Substring(0, dot); port =
int.Parse(ipaddAdndPort.Substring(dot + 1)); }
httpContext.Connection.RemoteIpAddress = System.Net.IPAddress.Parse(ip); if
(port != 0) httpContext.Connection.RemotePort = port; } } finally { await
_next(httpContext); } } }
Usage method: