JorgeCostaMacia.Http.ForwardedHeaders
5.1.1
Prefix Reserved
dotnet add package JorgeCostaMacia.Http.ForwardedHeaders --version 5.1.1
NuGet\Install-Package JorgeCostaMacia.Http.ForwardedHeaders -Version 5.1.1
<PackageReference Include="JorgeCostaMacia.Http.ForwardedHeaders" Version="5.1.1" />
<PackageVersion Include="JorgeCostaMacia.Http.ForwardedHeaders" Version="5.1.1" />
<PackageReference Include="JorgeCostaMacia.Http.ForwardedHeaders" />
paket add JorgeCostaMacia.Http.ForwardedHeaders --version 5.1.1
#r "nuget: JorgeCostaMacia.Http.ForwardedHeaders, 5.1.1"
#:package JorgeCostaMacia.Http.ForwardedHeaders@5.1.1
#addin nuget:?package=JorgeCostaMacia.Http.ForwardedHeaders&version=5.1.1
#tool nuget:?package=JorgeCostaMacia.Http.ForwardedHeaders&version=5.1.1
JorgeCostaMacia.Http.ForwardedHeaders
Forwarded-headers defaults for a service behind a reverse proxy — an options extension that trusts the proxy on the same host or on Docker's default bridge and honours its X-Forwarded-* headers, keeping the framework's Configure<ForwardedHeadersOptions> and UseForwardedHeaders calls visible in your Program.
Install
dotnet add package JorgeCostaMacia.Http.ForwardedHeaders
Usage
using JorgeCostaMacia.Http.ForwardedHeaders.Infrastructure;
builder.Services.Configure<ForwardedHeadersOptions>(options => options.WithDefaults());
var app = builder.Build();
app.UseForwardedHeaders(); // first in the pipeline, so everything after sees the client's address and scheme
Honours X-Forwarded-For, X-Forwarded-Proto and X-Forwarded-Host, and only from a trusted address: the loopbacks (127.0.0.1, 127.0.1.1, ::1) and Docker's default bridge (172.17.0.0/16), the network a proxy on the host reaches a published container from. Headers sent by anyone else are ignored, so a client cannot forge its address or scheme.
The trusted addresses are added to the framework's own. A service behind another proxy adds it after the defaults:
builder.Services.Configure<ForwardedHeadersOptions>(options =>
{
options.WithDefaults();
options.KnownProxies.Add(IPAddress.Parse("10.0.0.5"));
});
Requirements
The .NET 10 SDK.
Depends on the ASP.NET Core shared framework only.
About
JorgeCostaMacia.Http.ForwardedHeaders is part of http-dotnet — extensions for ASP.NET Core, each scoped to a single concern and reusable across your services. An independent project, not affiliated with Microsoft or the ASP.NET Core project.
- Repository: github.com/JorgeCostaMacia/http-dotnet
- Issues & requests: open an issue
- Contributing: CONTRIBUTING.md
- Security: report a vulnerability
Author: Jorge Costa Maciá
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.