pgAdmin4 unable to work behind Nginx reverse proxy running on a non-standard port.

Werkzeug middleware allows us to set the number of trusted ports and few other params
behind the proxy. By default values are set to zero.

Added 'X-Forwarded-*' configuration options and set the default value of the port to 1 to work with non-standard port.

Fixes #4768
This commit is contained in:
Aditya Toshniwal
2019-09-27 13:24:35 +05:30
committed by Akshay Joshi
parent 56e00d74ad
commit faf8062830
4 changed files with 44 additions and 1 deletions

View File

@@ -71,7 +71,13 @@ if not os.path.isfile(config.SQLITE_PATH):
class ReverseProxied(object):
def __init__(self, app):
# https://werkzeug.palletsprojects.com/en/0.15.x/middleware/proxy_fix/#module-werkzeug.middleware.proxy_fix
self.app = ProxyFix(app)
self.app = ProxyFix(app,
x_for=config.PROXY_X_FOR_COUNT,
x_proto=config.PROXY_X_PROTO_COUNT,
x_host=config.PROXY_X_HOST_COUNT,
x_port=config.PROXY_X_PORT_COUNT,
x_prefix=config.PROXY_X_PREFIX_COUNT
)
def __call__(self, environ, start_response):
script_name = environ.get("HTTP_X_SCRIPT_NAME", "")