Ensure that pgAdmin should work behind reverse proxy if the inbuilt server is used as it is. Fixes #4755

This commit is contained in:
Aditya Toshniwal 2019-09-23 11:50:32 +05:30 committed by Akshay Joshi
parent 1bef98fdfa
commit 82aa2d1819
2 changed files with 8 additions and 3 deletions

View File

@ -17,4 +17,5 @@ Housekeeping
Bug fixes Bug fixes
********* *********
| `Issue #4199 <https://redmine.postgresql.org/issues/4199>`_ - Ensure that 'ENTER' key in the data filter should not run the query. | `Issue #4199 <https://redmine.postgresql.org/issues/4199>`_ - Ensure that 'ENTER' key in the data filter should not run the query.
| `Issue #4755 <https://redmine.postgresql.org/issues/4755>`_ - Ensure that pgAdmin should work behind reverse proxy if the inbuilt server is used as it is.

View File

@ -13,6 +13,7 @@ to start a web server."""
import os import os
import sys import sys
from werkzeug.middleware.proxy_fix import ProxyFix
if sys.version_info[0] >= 3: if sys.version_info[0] >= 3:
import builtins import builtins
@ -69,7 +70,8 @@ if not os.path.isfile(config.SQLITE_PATH):
########################################################################## ##########################################################################
class ReverseProxied(object): class ReverseProxied(object):
def __init__(self, app): def __init__(self, app):
self.app = app # https://werkzeug.palletsprojects.com/en/0.15.x/middleware/proxy_fix/#module-werkzeug.middleware.proxy_fix
self.app = ProxyFix(app)
def __call__(self, environ, start_response): def __call__(self, environ, start_response):
script_name = environ.get("HTTP_X_SCRIPT_NAME", "") script_name = environ.get("HTTP_X_SCRIPT_NAME", "")
@ -95,7 +97,9 @@ if config.DEBUG:
# Create the app! # Create the app!
app = create_app() app = create_app()
app.wsgi_app = ReverseProxied(app.wsgi_app)
if config.SERVER_MODE:
app.wsgi_app = ReverseProxied(app.wsgi_app)
if config.DEBUG: if config.DEBUG:
app.debug = True app.debug = True