Fix X-Forwarded-* headers ignored when running in container

This commit is contained in:
James Chapman 2023-11-11 22:41:28 +00:00
parent 30e774da38
commit 8ea0c769d8
Signed by: jamsch0
GPG Key ID: 765FE58130277547

View File

@ -34,6 +34,13 @@ if (!dbUpgradeResult.Successful)
return -1; return -1;
} }
builder.Services.Configure<ForwardedHeadersOptions>(options =>
{
options.ForwardedHeaders = ForwardedHeaders.All;
options.KnownNetworks.Clear();
options.KnownProxies.Clear();
});
var dataProtection = builder.Services.AddDataProtection(); var dataProtection = builder.Services.AddDataProtection();
if (env.IsProduction()) if (env.IsProduction())
{ {
@ -86,7 +93,7 @@ builder.Services.AddDbContextPool<AppDbContext>(options => options
var app = builder.Build(); var app = builder.Build();
app.UseForwardedHeaders(new() { ForwardedHeaders = ForwardedHeaders.All }); app.UseForwardedHeaders();
app.UseStaticFiles(); app.UseStaticFiles();
app.UseRouting(); app.UseRouting();