Integrate with UseForwardedHeaders in the proxy
- Dominant language
- C#
- Stars
- 9.6k
- Forks
- 933
- Avg merge
- 12d 18h
- Merged PRs (30d)
- 2
Description
ASP.NET Core has a UseForwardedHeaders middleware that processes incoming x-forwarded-* headers and applies them to the request. Here are things it does:
- Updates HttpContext.Connection.RemoteIp/Port, Request.Scheme/Host, etc.
- Trims consumed values from the x-forwarded-* headers
- Adds x-original-* headers with the consumed values
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:
- Still update HttpContext.Connection.RemoteIp/Port, Request.Scheme/Host, etc.
- Store the original values in a new feature
- Don't modify the request headers
- Don't add the x-original request header, store this data in a feature instead.
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.
Contributor guide
Assessment
This issue has not been assessed yet.