mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Add support for reverse proxied setups with Gunicorn, and document Gunicorn, uWSGI & NGINX configurations. Fixes #2001
This commit is contained in:
@@ -57,6 +57,27 @@ if not os.path.isfile(config.SQLITE_PATH):
|
||||
)
|
||||
exec(open(file_quote(setupfile), 'r').read())
|
||||
|
||||
|
||||
##########################################################################
|
||||
# Support reverse proxying
|
||||
##########################################################################
|
||||
class ReverseProxied(object):
|
||||
def __init__(self, app):
|
||||
self.app = app
|
||||
|
||||
def __call__(self, environ, start_response):
|
||||
script_name = environ.get("HTTP_X_SCRIPT_NAME", "")
|
||||
if script_name:
|
||||
environ["SCRIPT_NAME"] = script_name
|
||||
path_info = environ["PATH_INFO"]
|
||||
if path_info.startswith(script_name):
|
||||
environ["PATH_INFO"] = path_info[len(script_name):]
|
||||
scheme = environ.get("HTTP_X_SCHEME", "")
|
||||
if scheme:
|
||||
environ["wsgi.url_scheme"] = scheme
|
||||
return self.app(environ, start_response)
|
||||
|
||||
|
||||
##########################################################################
|
||||
# Server startup
|
||||
##########################################################################
|
||||
@@ -68,6 +89,7 @@ if config.DEBUG:
|
||||
|
||||
# Create the app!
|
||||
app = create_app()
|
||||
app.wsgi_app = ReverseProxied(app.wsgi_app)
|
||||
|
||||
if config.DEBUG:
|
||||
app.debug = True
|
||||
|
||||
Reference in New Issue
Block a user