From be53503ec04576d5ef62602f87fdb7d59a6109b2 Mon Sep 17 00:00:00 2001 From: ta264 Date: Thu, 10 Jun 2021 21:59:11 +0100 Subject: [PATCH] Fixed: Bad login redirect using a reverse proxy (cherry picked from commit b0f04bb9d79a9f9f0021d179ea7273998be7cab3) (cherry picked from commit ee81ad2add4819920e17ab8b64165a8131ae8dd0) --- src/NzbDrone.Host/Startup.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/NzbDrone.Host/Startup.cs b/src/NzbDrone.Host/Startup.cs index 7037d3ce1..b94d25e9f 100644 --- a/src/NzbDrone.Host/Startup.cs +++ b/src/NzbDrone.Host/Startup.cs @@ -9,6 +9,7 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.HttpOverrides; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; @@ -47,6 +48,13 @@ public void ConfigureServices(IServiceCollection services) b.AddNLog(); }); + services.Configure(options => + { + options.ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto; + options.KnownNetworks.Clear(); + options.KnownProxies.Clear(); + }); + services.AddRouting(options => options.LowercaseUrls = true); services.AddResponseCompression(); @@ -143,6 +151,7 @@ public void Configure(IApplicationBuilder app, firewallAdapter.MakeAccessible(); } + app.UseForwardedHeaders(); app.UseMiddleware(); app.UsePathBase(new PathString(configFileProvider.UrlBase)); app.UseExceptionHandler(new ExceptionHandlerOptions