dotnet / dotnet/yarp

Integrate with UseForwardedHeaders in the proxy

Open
#642 6 comments 1 reaction 0 assignees View on GitHub
Type: Idea
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.