Skip to content

Granian http/https problem in Flask app #475

Answered by gi0baro
kingkong-cmd asked this question in Q&A
Discussion options

You must be logged in to vote

At current time, Granian won't use X-Forwarded headers to alter wsgi.url_scheme in WSGI environ, mainly 'cause there's no mention in WSGI spec that such value should be set using the mentioned headers.
While we can discuss wether this behavior should be changed in future releases, at the time being this can probably be "fixed" by either:

  • add SSL on Granian side and instruct nginx to communicate with the upstream via HTTPS
  • wrap your WSGI application into an utility which sets wsgi.url_scheme to https, eg:
def app_https_forw_wrapper(environ, start_response):
    if environ.get("HTTP_X_FORWARDED_PROTO") == "https":
        environ["wsgi.url_scheme"] = "https"
    return actual_app(environ, s…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@kingkong-cmd
Comment options

Answer selected by kingkong-cmd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants