Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add trusted networks #2387

Closed
wants to merge 2 commits into from
Closed

Conversation

b4stien
Copy link

@b4stien b4stien commented Jul 11, 2024

Deploying FastAPI in AWS behind an AWS Load Balancer I hit a roadblack to trust the proxy (the Load Balancer): I know its network but not its IPs. Using ProxyHeadersMiddleware as it is, I'd have to know those IPs beforehand to trust them.

Would you be willing to consider a slight modification to ProxyHeadersMiddleware to accept trusted_networks in addition to trusted_hosts?

Attached is some working code of how it would work.

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.

PS: I've opened a discussion, you can close this PR in the meantime if needed, it'll still reference some code ideas.

@Kludex
Copy link
Member

Kludex commented Oct 9, 2024

The current implementation works for trusted networks now. :)

@Kludex Kludex closed this Oct 9, 2024
@b4stien
Copy link
Author

b4stien commented Oct 9, 2024

Oh ok, wonderful! Could you provide a ref of the relevant commits implementing it? Or the docs for the feature?

@b4stien
Copy link
Author

b4stien commented Oct 9, 2024

This is #2468 and #2231, right?

@Kludex
Copy link
Member

Kludex commented Oct 9, 2024

This is #2468 and #2231, right?

Yes.

@Kludex
Copy link
Member

Kludex commented Oct 9, 2024

Oh ok, wonderful! Could you provide a ref of the relevant commits implementing it? Or the docs for the feature?

https://www.uvicorn.org/deployment/#proxies-and-forwarded-headers

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