diff --git a/docs/en_US/release_notes_4_14.rst b/docs/en_US/release_notes_4_14.rst index 2022152de..fa136b8d8 100644 --- a/docs/en_US/release_notes_4_14.rst +++ b/docs/en_US/release_notes_4_14.rst @@ -17,4 +17,5 @@ Housekeeping Bug fixes ********* -| `Issue #4199 `_ - Ensure that 'ENTER' key in the data filter should not run the query. \ No newline at end of file +| `Issue #4199 `_ - Ensure that 'ENTER' key in the data filter should not run the query. +| `Issue #4755 `_ - Ensure that pgAdmin should work behind reverse proxy if the inbuilt server is used as it is. \ No newline at end of file diff --git a/web/pgAdmin4.py b/web/pgAdmin4.py index fe22f51d8..2063603a6 100644 --- a/web/pgAdmin4.py +++ b/web/pgAdmin4.py @@ -13,6 +13,7 @@ to start a web server.""" import os import sys +from werkzeug.middleware.proxy_fix import ProxyFix if sys.version_info[0] >= 3: import builtins @@ -69,7 +70,8 @@ if not os.path.isfile(config.SQLITE_PATH): ########################################################################## class ReverseProxied(object): 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): script_name = environ.get("HTTP_X_SCRIPT_NAME", "") @@ -95,7 +97,9 @@ if config.DEBUG: # Create the 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: app.debug = True