diff --git a/lib/galaxy/web/framework/middleware/xforwardedhost.py b/lib/galaxy/web/framework/middleware/xforwardedhost.py index 3376fd03c953..04216dbe490f 100644 --- a/lib/galaxy/web/framework/middleware/xforwardedhost.py +++ b/lib/galaxy/web/framework/middleware/xforwardedhost.py @@ -9,10 +9,10 @@ def __init__(self, app, global_conf=None): def __call__(self, environ, start_response): if x_forwarded_host := environ.get("HTTP_X_FORWARDED_HOST", None): - environ["ORGINAL_HTTP_HOST"] = environ["HTTP_HOST"] + environ["ORIGINAL_HTTP_HOST"] = environ.get("HTTP_HOST") environ["HTTP_HOST"] = x_forwarded_host.split(", ", 1)[0] if x_forwarded_for := environ.get("HTTP_X_FORWARDED_FOR", None): - environ["ORGINAL_REMOTE_ADDR"] = environ["REMOTE_ADDR"] + environ["ORIGINAL_REMOTE_ADDR"] = environ.get("REMOTE_ADDR") environ["REMOTE_ADDR"] = x_forwarded_for.split(",", 1)[0].strip() x_forwarded_proto = environ.get("HTTP_X_FORWARDED_PROTO", None) if x_forwarded_proto: