Skip to content

Commit 92d2dc8

Browse files
committed
middleware for forwarding headers
1 parent eee8a69 commit 92d2dc8

3 files changed

Lines changed: 28 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
# 0.19.3 <small>2026-04-29</small>
2+
3+
## 🐛 Bug Fixes
4+
- Add forwarded headers middleware to `Site/Program.cs` so that links (e.g. download URLs) are
5+
generated with `https://` when the app runs behind a reverse proxy such as an AWS ALB or Azure
6+
Application Gateway that terminates TLS. Without this, the container sees plain HTTP and generates
7+
`http://` links, which can break downloads due to auth cookies being stripped on redirect.
8+
9+
<!-- CHANGELOG_BOUNDARY -->
10+
111
# 0.19.2 <small>2026-04-29</small>
212

313
## 💅 Improvements

src/OrchardCore.Transformalize/OrchardCore.Transformalize.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
<TargetFramework>net10.0</TargetFramework>
44
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
55
<RootNamespace>TransformalizeModule</RootNamespace>
6-
<Version>0.19.1</Version>
7-
<FileVersion>0.19.1</FileVersion>
8-
<AssemblyVersion>0.19.1</AssemblyVersion>
6+
<Version>0.19.3</Version>
7+
<FileVersion>0.19.3</FileVersion>
8+
<AssemblyVersion>0.19.3</AssemblyVersion>
99
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
1010
<Authors>Dale Newman</Authors>
1111
<Copyright>Copyright © 2013-2026</Copyright>

src/Site/Program.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using Microsoft.AspNetCore.HttpOverrides;
12
using Serilog;
23

34
var builder = WebApplication.CreateBuilder(args);
@@ -32,6 +33,20 @@
3233
app.UseHsts();
3334
}
3435

36+
// Trust X-Forwarded-For and X-Forwarded-Proto headers so that generated links use the correct
37+
// scheme (https) when the app runs in a private subnet behind a public-facing reverse proxy
38+
// (e.g. AWS ALB, Azure Application Gateway). Without this, the container only sees http and
39+
// generates http:// links, which can cause auth cookies to be stripped on redirect and break
40+
// downloads. KnownIPNetworks/KnownProxies are cleared so any upstream proxy is trusted —
41+
// this is safe when the container is not directly reachable from the internet, but would allow
42+
// header spoofing if the app were exposed publicly without a proxy in front of it.
43+
var forwardedOptions = new ForwardedHeadersOptions {
44+
ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
45+
};
46+
forwardedOptions.KnownIPNetworks.Clear();
47+
forwardedOptions.KnownProxies.Clear();
48+
app.UseForwardedHeaders(forwardedOptions);
49+
3550
// app.UseHttpsRedirection();
3651
app.UseStaticFiles();
3752

0 commit comments

Comments
 (0)