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

trust_number_of_proxies to ProxyHeadersMiddleware #2508

Closed
wants to merge 1 commit into from

Conversation

mzealey
Copy link

@mzealey mzealey commented Nov 11, 2024

Summary

The motivation for this is if you know you are behind eg loadbalancer + reverse-proxy nginx, but their IPs are not sensibly known (eg they change), you can configure the middleware to just skip the known number of them before applying any other heuristics. This should be backwards-compatible with previous versions of the middleware. This makes it easier to port code from https://werkzeug.palletsprojects.com/en/stable/middleware/proxy_fix/

Adds a new setting of trusted_number_of_proxies to the
ProxyHeadersMiddleware that allows the user to specify the number of
proxies that are trusted to be present in the request and not otherwise
verified.

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.

Adds a new setting of `trusted_number_of_proxies` to the
`ProxyHeadersMiddleware` that allows the user to specify the number of
proxies that are trusted to be present in the request and not otherwise
verified.
@mzealey
Copy link
Author

mzealey commented Nov 11, 2024

(the tests currently seem to be failing due to the tests on master branch being broken?)

@Kludex
Copy link
Member

Kludex commented Nov 20, 2024

Please create a discussion first.

@Kludex Kludex closed this Nov 20, 2024
@mzealey
Copy link
Author

mzealey commented Nov 21, 2024

Opened in #2519

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