microsoft / reverse-proxy

A toolkit for developing high-performance HTTP reverse proxy applications.
https://microsoft.github.io/reverse-proxy
MIT License
8.54k stars 838 forks source link

Integrate with UseForwardedHeaders in the proxy #642

Open Tratcher opened 3 years ago

Tratcher commented 3 years ago

ASP.NET Core has a UseForwardedHeaders middleware that processes incoming x-forwarded-* headers and applies them to the request. Here are things it does:

That middleware design assumes the app is the endpoint, it doesn't work well if the request is going to be forwarded since it's modified the request headers and fields. Today's proxy x-forwarded transforms would technically work since they'd take the current RemoteIp/Port/Scheme/Host fields from the requests and append them to the headers, but intermediate values from those headers would be lost.

UseForwardedHeaders probably needs some (opt-in?) design updates:

The proxy's x-forwarded transform logic would need to check for the new feature with the original values and use those rather than the current values.

karelz commented 3 years ago

Triage: Either ASP.NET makes the middleware more proxy friendly, or fork it. For v1 guidance might be sufficient

Tratcher commented 3 years ago

Related: #1331

samsp-msft commented 2 years ago

This seems to be more of an issue with the middleware, rather than YARP. I'm wondering if this should be tracked with an issue in ASP.NET repo for .NET 7 rather than YARP.

karelz commented 2 years ago

@adityamandaleeka we will need ASP.NET 7.0 middleware work to light this up in YARP.

adityamandaleeka commented 2 years ago

Thanks @karelz. @Tratcher is there an issue filed in aspnetcore for this already?

Tratcher commented 2 years ago

I've opened https://github.com/dotnet/aspnetcore/issues/39423. We'll want to react to those changes in YARP when they are available.