Commit 3d1fa9f0 authored by Langhammer, Jens's avatar Langhammer, Jens

app_gw: Rewrite redirect responses (replace upstream location with server_name)

parent 1d2be6e6
Pipeline #3895 passed with stage
in 2 minutes and 19 seconds
...@@ -221,5 +221,13 @@ class RequestHandler: ...@@ -221,5 +221,13 @@ class RequestHandler:
self._set_content_type(proxy_response) self._set_content_type(proxy_response)
response = get_django_response(proxy_response, strict_cookies=False) response = get_django_response(proxy_response, strict_cookies=False)
# If response has a 'Location' header, we rewrite that location as well
if 'Location' in response:
LOGGER.debug("Rewriting Location header")
for server_name in self.app_gw.server_name:
response['Location'] = response['Location'].replace(
self._parsed_url.hostname, server_name)
LOGGER.debug(response['Location'])
# LOGGER.debug("RESPONSE RETURNED: %s", response) # LOGGER.debug("RESPONSE RETURNED: %s", response)
return response return response
...@@ -9,7 +9,7 @@ from passbook.app_gw.proxy.utils import (cookie_from_string, ...@@ -9,7 +9,7 @@ from passbook.app_gw.proxy.utils import (cookie_from_string,
#: Default number of bytes that are going to be read in a file lecture #: Default number of bytes that are going to be read in a file lecture
DEFAULT_AMT = 2 ** 16 DEFAULT_AMT = 2 ** 16
logger = logging.getLogger('revproxy.response') logger = logging.getLogger(__name__)
def get_django_response(proxy_response, strict_cookies=False): def get_django_response(proxy_response, strict_cookies=False):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment