NetLah.Extensions.HttpOverrides is a library support setting ASP.NET Core HttpOverrides from configuration.
<ItemGroup>
<PackageReference Include="NetLah.Extensions.HttpOverrides" Version="1.0.0" />
</ItemGroup>
builder.Services.AddHttpOverrides(builder.Configuration);
app.UseHttpOverrides(logger);
This HttpOverrides will check configuration ASPNETCORE_FORWARDEDHEADERS_ENABLED or ForwardedHeaders_Enabled not turned on to not override default behavior of ASP.NETCore.
Reference ForwardedHeadersOptionsSetup.cs
{
"HealthCheck": {
"IsEnabled": true,
"IsAzureAppServiceContainer": false, // will include /healthz and /robots933456.txt
"LogLevel": "Debug",
"Path": "/healthz",
"Paths": [ "/healthz", "/robots933456.txt" ],
"Port": null,
"Prefix": null,
"Suffix": null,
"RemoveResponseWriter": false
},
"HttpOverrides": {
"ClearForwardLimit": false,
"ClearKnownProxies": false,
"ClearKnownNetworks": false,
"ForwardLimit": 1,
"KnownProxies": "::1",
"KnownNetworks": "127.0.0.1/8",
"ForwardedForHeaderName": "X-Forwarded-For",
"ForwardedHostHeaderName": "X-Forwarded-Host",
"ForwardedProtoHeaderName": "X-Forwarded-Proto",
"OriginalForHeaderName": "X-Original-For",
"OriginalHostHeaderName": "X-Original-Host",
"OriginalProtoHeaderName": "X-Original-Proto",
"ForwardedHeaders": "", // XForwardedFor,XForwardedHost,XForwardedProto
"AllowedHosts": "" // "*"
}
}