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

ForwardedHeadersMiddleware - no ability to configure accept_only_proxied_requests #274

Open
virajkanwade opened this issue Aug 16, 2022 · 1 comment
Labels
enhancement New feature or request low priority

Comments

@virajkanwade
Copy link

Describe the bug
A description of what the bug is, possibly including how to reproduce it.

The flag, accept_only_proxied_requests, is hardcoded to True

self.accept_only_proxied_requests = True

Override should be allowed in the constructor.

Would be useful in cloud where load balancer will be used, but monitoring scripts would use the instance local ip.

@RobertoPrevato RobertoPrevato added the enhancement New feature or request label Aug 18, 2022
@RobertoPrevato
Copy link
Member

Hi!
Thank You for reporting this issue. You are right that the class should allow configuring that property in the constructor, this can be easily fixed.

It is not a blocking bug, though, as it's always possible to set the property after instantiating the class:

@app.on_middlewares_configuration
def configure_forwarded_headers(app):
    forward_middleware = ForwardedHeadersMiddleware()
    forward_middleware.accept_only_proxied_requests = False

    app.middlewares.insert(
        0,
        forward_middleware,
    )

instead of:

@app.on_middlewares_configuration
def configure_forwarded_headers(app):
    app.middlewares.insert(
        0,
        ForwardedHeadersMiddleware(),
    )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request low priority
Projects
None yet
Development

No branches or pull requests

2 participants