dotnet / dotnet/aspnetcore

UseForwardedHeaders should not manipulate headers

Open
#39,423 2 comments 3 reactions 0 assignees View on GitHub
area-networking design-proposal Needs: Design
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 10h
Merged PRs (30d)
281

Description

RE: https://github.com/microsoft/reverse-proxy/issues/642

## Summary

UseFowarardedHeaders makes some design choices that make it interop poorly with proxies like YARP. It's also inconsistent compared to how other middleware interact with the request.

## Motivation and goals

- The middleware modifies the incoming x-forwarded-* headers, making them difficult to append to and forward in a proxy.
- The middleware stores the original values in x-original-* headers, rather than putting them in a Feature like other components. These x-original-* headers end up getting proxied and the destination doesn't know what to do with them.

# Detailed design

- 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.

When proxy code wants to append to x-forwarded-* headers it would need to check for the new feature for the original values of scheme, host, port, etc.

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.