Skip to content

Add support for multiple values for the x-forwarded-proto header#2104

Closed
vanschelven wants to merge 2 commits intoKludex:masterfrom
vanschelven:multiple-forwarded-ports
Closed

Add support for multiple values for the x-forwarded-proto header#2104
vanschelven wants to merge 2 commits intoKludex:masterfrom
vanschelven:multiple-forwarded-ports

Conversation

@vanschelven
Copy link
Copy Markdown

See #2102

When uvicorn is deployed behind more than one proxy, the proxy behavior is sometimes to list the protocol as a comma-separated list.

However, currently, uvicorn expects only one value for the x-forwarded-proto header, instead of parsing it as a list of values and setting the protocol accordingly.

x-forwarded-proto is a non-standard header, so there isn't a specification for its use, but different reverse-proxy vendors do use it in different ways, and some append the protocol as a comma-separated value from left-to-right (left being the furthermost proxy and rightmost being the closest).

Checklist

  • I understand that this PR may be closed in case there was no previous discussion. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I'm a volunteer myself who's happy to provide a drive-by commit as a direction for a solution but cannot spend more time on this right now

@Kludex
Copy link
Copy Markdown
Owner

Kludex commented Mar 2, 2024

I don't see much literature about receiving a comma-separated list. The main references I could find have either "https" or "http".

@Kludex Kludex closed this Mar 2, 2024
@vanschelven
Copy link
Copy Markdown
Author

vanschelven commented Mar 2, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants