Editing a URL's Redirect Header
In the context of URL redirection, API or web services will modify a response's Redirect Headers to guide clients toward a new URL or path. More information on URL redirection can be found in the MDN Web Documentation.
It's important to note a proxied service's ability to rewrite the Location and Refresh Redirect Headers when introducing a Corsha Gatekeeper into the request/response workflow. When a Corsha Gatekeeper is configured in front of an API service, the API service should no longer be exposed to API clients and the original hostname of the API service instead directs to the Corsha Gatekeeper. However there are some cases in which the original API service's hostname is not used for the Corsha Gatekeeper.
When the upstream API service rewrites a response's Redirect Headers, the rewritten location may reflect the original API hostname rather than the Corsha Gatekeeper's hostname. To accommodate this, the Corsha Gatekeeper can replace all Redirect header with the correct hostname, ensuring seamless client redirection to the right location, even when the requested resource is behind a Corsha Gatekeeper.
Docker Deployment Configuration
Editing the Redirect Location Header can be done by adding config to proxy-config.yaml. Simply set the targeted
service's rewriteRedirect config as seen below:
http:
listenPort: 8080
proxies:
- name: proxy
domain: proxy
upstream:
host: "api" # the proxied tcp service
port: 4880
protocol: TCP
rewriteRedirect:
enabled: true
redirect: "https://api" # The redirect url that needs to be updated. This variable is often the same as `proxies[].upstream.host`.
replacement: "https://proxy" # What the redirect url should be updated to. This variable is often the same as `proxies[].domain`.
Helm Deployment Configuration
Editing the Redirect Location Header can be done by editing the Gatekeeper's values.yaml. Simply set the targeted
service's rewriteRedirect config as seen below:
http:
listenPort: 8080
proxies:
- name: proxy
domain: proxy
upstream:
host: "api" # the proxied tcp service
port: 4880
protocol: TCP
rewriteRedirect:
enabled: true
redirect: "https://api" # The redirect url that needs to be updated. This variable is often the same as `proxies[].upstream.host`.
replacement: "https://proxy" # What the redirect url should be updated to. This variable is often the same as `proxies[].domain`.
When the rewriteRedirect value is used, all http responses with a non null Refresh header or Location header will be replaced.