Skip to content

Commit df6428f

Browse files
authored
Merge pull request #823 from DuendeSoftware/ev/bff/auto-wireup
auto-wireup & xforward docs
2 parents d881cb1 + ca97c96 commit df6428f

File tree

2 files changed

+27
-8
lines changed

2 files changed

+27
-8
lines changed

src/content/docs/bff/architecture/multi-frontend.md

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,19 +67,13 @@ If you don't want this automatic mapping of BFF middleware, you can turn it off
6767
```csharp
6868
var app = builder.Build();
6969

70-
app.UseBffFrontendSelection();
71-
app.UseBffPathMapping();
72-
app.UseBffOpenIdCallbacks();
70+
app.UseBffPreProcessing();
7371

7472
// TODO: your custom middleware goes here
7573
app.UseRouting();
7674
app.UseBff();
7775

78-
// NOTE: Only add this if you want to proxy remote APIs.
79-
app.UseBffRemoteRoutes();
80-
81-
app.MapBffManagementEndpoints();
82-
app.UseBffIndexPages();
76+
app.UseBffPostProcessing();
8377

8478
app.Run();
8579
```

src/content/docs/bff/fundamentals/options.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,3 +200,28 @@ The following options are available:
200200
BffClientAuthenticationStateProvider to the /bff/user endpoint. Defaults to 5000
201201
ms.
202202

203+
204+
# Proxy Servers and Load Balancers :badge[v4.0]
205+
206+
When your BFF is hosted behind another reverse proxy or load balancer, you'll want to use `X-Forwarded-*` headers.
207+
208+
BFF automatically registers the `ForwardedHeaders` middleware in the pipeline, without any additional configuration. You will need to configure which headers should be considered by the middleware, typically the `X-Forwarded-For` and `X-Forwarded-Proto` headers. Here's an example of how you can configure this.
209+
210+
```csharp
211+
// Program.cs
212+
builder.Services.Configure<ForwardedHeadersOptions>(options =>
213+
{
214+
// Consider configuring the 'KnownProxies' and the 'AllowedHosts' to prevent IP spoofing attacks
215+
options.ForwardedHeaders =
216+
ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto;
217+
});
218+
```
219+
220+
See [proxy servers and load balancers](https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/proxy-load-balancer?view=aspnetcore-9.0) in the Microsoft documentation for more information.
221+
222+
:::note
223+
Be careful processing `X-Forwarded-*` headers from untrusted sources. Accepting these headers without validating the proxy IP address or network origin may leave you vulnerable to IP Spoofing attacks.
224+
225+
See [Microsoft Security Advisory CVE-2018-0787](https://github.com/aspnet/Announcements/issues/295) for information
226+
on an elevation-of-privileges vulnerability that affects systems where the proxy doesn't validate or restrict `Host` headers to known good values.
227+
:::

0 commit comments

Comments
 (0)