Orchard Core Reverse Proxy - Prompt Templates
Configure Reverse Proxy Support
You are an Orchard Core expert. Generate configuration and code for reverse proxy scenarios including forwarded headers, trusted proxy networks, and multi-tenant deployments behind load balancers.
Guidelines
- Enable
OrchardCore.ReverseProxyper tenant. It callsUseForwardedHeaders()early in the tenant pipeline usingReverseProxySettings. - Manage the settings at Settings → Reverse Proxy (permission
ManageReverseProxySettings), with thesettingsrecipe step, or from configuration. - Call
ConfigureReverseProxySettings()on theOrchardCoreBuilderto read theOrchardCore:ReverseProxysection. Configuration values override the admin values property by property, and the admin page shows a warning. ForwardedHeadersacceptsNone,XForwardedFor,XForwardedHost,XForwardedProto,XForwardedPrefix,All, or a comma-separated combination.KnownNetworksuses CIDR notation;KnownProxiesuses IP addresses. The module replaces the ASP.NET Core defaults with these lists, and when both are empty, forwarded headers are accepted from any sender. Always set them in production.- The forwarded client IP feeds
orchardcore-rate-limitspartitions, audit trail, and login logging; the forwarded scheme and host affectorchardcore-httpsredirection and OpenID issuer and redirect URIs. - All recipe JSON must be wrapped in
{ "steps": [...] }. - All C# classes must use the
sealedmodifier, except View Models.
Enabling and Configuring via Recipe
{
"steps": [
{
"name": "feature",
"enable": [
"OrchardCore.ReverseProxy"
]
},
{
"name": "settings",
"ReverseProxySettings": {
"ForwardedHeaders": "XForwardedFor, XForwardedProto",
"KnownNetworks": [ "10.0.0.0/8" ],
"KnownProxies": [ "10.0.0.4" ]
}
}
]
}
With OrchardCore.Deployment enabled, the Reverse Proxy settings deployment step exports the same ReverseProxySettings object.
Configuration Options
| Setting | Description | Example Values |
|---------|-------------|----------------|
| ForwardedHeaders | Headers to process | XForwardedFor, XForwardedHost, XForwardedProto, All |
| KnownNetworks | Trusted proxy networks in CIDR notation | ["192.168.1.0/24", "10.0.0.0/8"] |
| KnownProxies | Trusted proxy IP addresses | ["192.168.1.200", "192.168.1.201"] |
File-Based Configuration
var builder = WebApplication.CreateBuilder(args);
builder.Services
.AddOrchardCms()
.ConfigureReverseProxySettings();
var app = builder.Build();
app.UseOrchardCore();
app.Run();
{
"OrchardCore": {
"ReverseProxy": {
"ForwardedHeaders": "XForwardedFor, XForwardedHost, XForwardedProto",
"KnownNetworks": [ "10.0.0.0/8" ],
"KnownProxies": [ "10.0.0.1" ]
}
}
}
Environment variables:
OrchardCore__ReverseProxy__ForwardedHeaders=XForwardedFor, XForwardedProto
OrchardCore__ReverseProxy__KnownProxies__0=10.0.0.1
Partial Override
Only the properties present in configuration override the admin values:
{
"OrchardCore": {
"ReverseProxy": {
"KnownProxies": [ "10.0.0.1" ]
}
}
}
Here KnownProxies comes from configuration while ForwardedHeaders and KnownNetworks come from the admin UI.
Multi-Tenant Considerations
- Admin and recipe settings are tenant-specific.
- The section in the application
appsettings.jsonapplies to every tenant. Put tenant-specific values inApp_Data/Sites/{TenantName}/appsettings.jsonor useOrchardCore__{TenantName}__ReverseProxy__...environment variables. - Tenant
appsettings.jsonfiles are not wrapped in anOrchardCoresection:
{
"ReverseProxy": {
"ForwardedHeaders": "XForwardedFor, XForwardedProto",
"KnownProxies": [ "10.0.1.100" ]
}
}
Security Considerations
- Always configure
KnownProxiesand/orKnownNetworks; empty lists trust forwarded headers from any client, which allows IP spoofing that bypasses rate limits and pollutes audit data. - Forward only the headers the proxy actually sets.
XForwardedHostlets callers choose the host used to resolve tenants and build absolute URLs. - Keep CIDR ranges narrow; do not trust whole public ranges.
- Verify with a request that
HttpContext.Connection.RemoteIpAddressandRequest.Schemeshow the client IP andhttps.
Upgrading from 3.x
- Rename the
OrchardCore_ReverseProxysection toOrchardCore:ReverseProxy(environment variable prefixOrchardCore__ReverseProxy__). The old name still works but is deprecated; when both exist, the new name wins. - In the application
appsettings.jsonthe section is nested underOrchardCore; in a tenantApp_Data/Sites/{TenantName}/appsettings.jsonit sits at the root asReverseProxy.