diff --git a/CaddyManager/Configurations/Application/ApplicationInfo.cs b/CaddyManager/Configurations/Application/ApplicationInfo.cs
index d9f31f7..2de77b2 100644
--- a/CaddyManager/Configurations/Application/ApplicationInfo.cs
+++ b/CaddyManager/Configurations/Application/ApplicationInfo.cs
@@ -8,7 +8,7 @@ public class ApplicationInfo
///
/// The version of the application, to be defined and tagged
///
- public static readonly string Version = "1.2.1";
+ public static readonly string Version = "1.2.2";
///
/// The commit hash of the application
diff --git a/CaddyManager/Program.cs b/CaddyManager/Program.cs
index cf7e6f6..e41682c 100644
--- a/CaddyManager/Program.cs
+++ b/CaddyManager/Program.cs
@@ -1,6 +1,7 @@
using CaddyManager.Api;
using CaddyManager.Components;
using Microsoft.AspNetCore.Components.Server;
+using Microsoft.AspNetCore.HttpOverrides;
using Microsoft.OpenApi;
using MudBlazor.Services;
using NetCore.AutoRegisterDi;
@@ -56,6 +57,19 @@ builder.Services.AddOpenApi(options =>
});
});
+// Caddy terminates TLS and forwards plain HTTP, so without this the app thinks every request is
+// http and the OpenAPI document advertises http:// server URLs, which the browser blocks as mixed
+// content when the docs page itself was served over https
+builder.Services.Configure(options =>
+{
+ options.ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto |
+ ForwardedHeaders.XForwardedHost;
+ // The proxy is another container on a Docker network, so its address is not known up front;
+ // this app is only ever meant to be reached through that proxy
+ options.KnownIPNetworks.Clear();
+ options.KnownProxies.Clear();
+});
+
builder.Services.AddMudServices(config =>
{
config.SnackbarConfiguration.VisibleStateDuration = 4000;
@@ -65,6 +79,9 @@ builder.Services.AddMudServices(config =>
var app = builder.Build();
+// Has to run before anything that reads the scheme, host or client address
+app.UseForwardedHeaders();
+
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{