21-Jul-2023 10:09
Hi all,
I am trying to rewrite the part of Path URI using LTM Policy but the problem is when the Path URI gets rewritten the whole URI is rewritten without keeping the rest of the path.
So for example, and I am pasting my exact rule just masked the parts because of information disclosure, when the request is: https://www.mydomain1.com/path1/v2/d/the_rest_of_the_path I want to rewrite /path1/v2/d into /path/app and then add the rest of the path content: https://www.mydomain1.com/path1/v2/d/beta/search?q=test
into https://www.mydomain1.com/path/app/beta/search?q=test
But what I get is: https://www.mydomain1.com/path/app/ and the rest is cut off.
Does anyone have a suggestion using GUI interface without resorting to iRule?
Thanks,
Igor
21-Jul-2023 14:38
@igor_ Sadly I'm far familiar with iRules than traffic policies so I'm not sure if you can do this in a traffic policy. What you want to do is a string map rather than a rewrite and the string you want to map is "/path1/v2/d" to "/path/app" which should conver the path as it traverses the F5 VS and is sent to the pool members.
24-Jul-2023 11:48
So @igor_ , what @Paulius is saying here is to use the local traffic policy, but you can use Tcl in it to avoid the separate iRule:
rewrite_uri_path_partial {
actions {
0 {
http-uri
replace
value "tcl:[string map {/path1/v2/d/ /path/app/} [HTTP::uri]]"
}
}
conditions {
0 {
http-uri
path
starts-with
values { /path1/v2/d/ }
}
}
ordinal 1
}
24-Jul-2023 06:39
Try using URL rewrite profile as it is available even without APM:
24-Jul-2023 12:15 - edited 24-Jul-2023 12:20
Hey thanks all for the answers. I managed to do the rewrite using a string map someone mentioned.
https://my.f5.com/manage/s/article/K16533717
I will try the solution @Nikoolayy1 pointed out also since I am more in favor of using GUI.
Also @JRahm since I am not familiar with TCL I will have to look into it also further. Thanks.
24-Jul-2023 13:16
I haven't used the rewrite profile operationally before, so I'm not sure if it's absolute or relative in what it replaces, but in looking at the config, seems possible on a request if it is a pattern match rather than an absolute path match:
create the profile, then attach to your virtual server. Your test virtual server of course... 😎