Merge "Use X-Forwarded-Proto as origin protocol if present"

This commit is contained in:
Zuul 2022-04-27 06:47:51 +00:00 committed by Gerrit Code Review
commit ce980f7dee
1 changed files with 7 additions and 0 deletions

View File

@ -283,6 +283,13 @@ class ZunProxyRequestHandlerBase(object):
origin = urlparse.urlparse(origin_url)
origin_hostname = origin.hostname
origin_scheme = origin.scheme
# If the console connection was forwarded by a proxy (example:
# haproxy), the original protocol could be contained in the
# X-Forwarded-Proto header instead of the Origin header. Prefer the
# forwarded protocol if it is present.
forwarded_proto = self.headers.get('X-Forwarded-Proto')
if forwarded_proto is not None:
origin_scheme = forwarded_proto
if origin_hostname == '' or origin_scheme == '':
detail = _("Origin header not valid.")
raise exception.ValidationError(detail)