This commit is contained in:
Simon 2021-10-03 03:48:30 +01:00
parent bacb791ba9
commit 55486aaedd
1 changed files with 10 additions and 6 deletions

View File

@ -4,10 +4,19 @@ using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Authentication.OpenIdConnect;
using Microsoft.AspNetCore.HttpOverrides;
using Microsoft.Extensions.Configuration;
using System.Collections;
var builder = WebApplication.CreateBuilder(args);
var Configuration = builder.Configuration;
builder.Services.Configure<ForwardedHeadersOptions>(options =>
{
options.ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto;
options.KnownNetworks.Clear();
options.KnownProxies.Clear();
});
// Add services to the container.
builder.Services.AddRazorPages();
builder.Services.AddControllers();
@ -31,12 +40,7 @@ builder.Services.AddAuthentication(options => {
var app = builder.Build();
app.UseForwardedHeaders(new ForwardedHeadersOptions
{
RequireHeaderSymmetry = false,
ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
});
app.UseForwardedHeaders();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())