From 3c936b1652f464f3a62724c4b64d356169554ed4 Mon Sep 17 00:00:00 2001 From: Daniel Grossmann-Kavanagh Date: Tue, 8 Jan 2019 18:56:55 -0800 Subject: [PATCH] wsgi.py: add credit to flask snippet, add docstring --- connexion/wsgi.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/connexion/wsgi.py b/connexion/wsgi.py index 6bdf14c6f..9c66e124f 100644 --- a/connexion/wsgi.py +++ b/connexion/wsgi.py @@ -1,4 +1,27 @@ +# adapted from http://flask.pocoo.org/snippets/35/ + + class ReverseProxied(object): + '''Wrap the application in this middleware and configure the + reverse proxy to add these headers, to let you quietly bind + this to a URL other than / and to an HTTP scheme that is + different than what is used locally. + + In nginx: + + location /proxied { + proxy_pass http://192.168.0.1:5001; + proxy_set_header Host $host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Scheme $scheme; + proxy_set_header X-Script-Name /proxied; + } + + :param app: the WSGI application + :param script_name: override the default script name (path) + :param scheme: override the default scheme + :param server: override the default server + ''' def __init__(self, app, script_name=None, scheme=None, server=None): self.app = app