08-Sep-2022 09:55
Hi I'm kind of surprised I haven't been able to find a simple answer for this.
We need to redirect (also see requirements below):
https://foo.bar.com/authorize/aaa/bbb/someFile.jsp?response_type=<some_dynamic_value>&client_id=<some_dynamic_value>&scope=<some_dynamic_value>&redirect_uri=<some_dynamic_value>
to
https://xxx.baz.com/authorize/aaa/bbb/someFile.jsp?response_type=<same_dynamic_value_from_request>&client_id=<same_dynamic_value_from_request>&scope=<same_dynamic_value_from_request>&redirect_uri=<same_dynamic_value_from_request>
Requirement #1: we can't use pools or policies.
Requirement #2: Only change the requests coming in where the path starts with /authorize (e.g. https://foo.bar.com/authorize/etc. gets redirected). Other requests hitting the host with a different start to the path must remain unchanged (e.g. https://foo.bar.com/billling must stay the same).
Requirement #2: With a simple redirect, we want to change the host name only, and keep the paths in the redirect the same as in the request and keep all query params and their values in the redirect the same as in the request (values change dynamically with each request)
08-Sep-2022 10:28
The following should do the job:
when HTTP_REQUEST {
if { [HTTP::uri] starts_with "/authorize/" } {
HTTP::redirect "https://xxx.baz.com[HTTP::uri]"
}
}
[HTTP::uri] captures the entire URI path, ex.
/authorize/aaa/bbb/someFile.jsp?response_type=abc&client_id=def&scope=ghi&redirect_uri=jkl
HTTP::path] captures the URI without the querystring, ex.
/authorize/aaa/bbb/someFile.jsp
[HTTP::query] captures just the querystring, ex.
response_type=abc&client_id=def&scope=ghi&redirect_uri=jkl
09-Sep-2022 05:15 - edited 09-Sep-2022 05:17
Are u able to explaine why "Requirement #1: we can't use pools or policies." ?
I recommend everyone to use LTM Policys instead of iRule wherever its possible.
But @Kevin_Stewart has the solution for iRule based redirect 🙂