support forwarding headers

This commit is contained in:
Paul Schneider 2023-04-09 03:28:02 +01:00
commit 47a66ba93a

View file

@ -28,6 +28,7 @@ using System.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
using isnd.Data.Catalog; using isnd.Data.Catalog;
using Newtonsoft.Json; using Newtonsoft.Json;
using Microsoft.AspNetCore.HttpOverrides;
namespace isnd namespace isnd
{ {
@ -50,6 +51,12 @@ namespace isnd
var adminStartupListConf = Configuration.GetSection("AdminList"); var adminStartupListConf = Configuration.GetSection("AdminList");
var unleashConf = Configuration.GetSection("Unleash"); var unleashConf = Configuration.GetSection("Unleash");
services.Configure<ForwardedHeadersOptions>(options =>
{
options.ForwardedHeaders =
ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto;
});
services.Configure<SmtpSettings>(smtpSettingsconf) services.Configure<SmtpSettings>(smtpSettingsconf)
.Configure<IsndSettings>(isndSettingsconf) .Configure<IsndSettings>(isndSettingsconf)
.Configure<AdminStartupList>(adminStartupListConf) .Configure<AdminStartupList>(adminStartupListConf)
@ -140,6 +147,7 @@ namespace isnd
ApplicationDbContext dbContext, ApplicationDbContext dbContext,
IOptions<IsndSettings> isnSettingsOption) IOptions<IsndSettings> isnSettingsOption)
{ {
app.UseForwardedHeaders();
if (env.IsDevelopment()) if (env.IsDevelopment())
{ {
app.UseDeveloperExceptionPage(); app.UseDeveloperExceptionPage();