17-Apr-2019
08:23
- last edited on
01-Jun-2023
15:08
by
JimmyPackets
I'm working on finding a solution for being able to match a query parameter by string and essentially "find and replace" the parameter using an iRule? Something that would essentially look like the following:
Request In: https://yadayada.com/ui/webconsole.html?vmId=ImAVM&vmName=DefinitelyALegitVM&userID=OneRandomlyGeneratedString&host=vcenter222.dev.ops&locale=en-U
iRule processing...
Request Out: https://yadayada.com/ui/webconsole.html?vmId=ImAVM&vmName=DefinitelyALegitVM&userID=OneRandomlyGeneratedString&host=vcenter-server333.dev.ops&locale=en-U
Is there an example iRule for accomplishing something along these lines that works around there being a randomly generated parameter?
[edit] Added a parameter that is randomly generated
17-Apr-2019 08:40
You may try with below:
when HTTP_REQUEST { if { ([string tolower [HTTP::uri]] equals "/ui/webconsole.html?vmId=ImAVM&vmName=DefinitelyALegitVM&host=vcenter222.dev.ops&locale=en-U") } { HTTP::redirect "https://[HTTP::host]/ui/webconsole.html?vmId=ImAVM&vmName=DefinitelyALegitVM&host=vcenter-server333.dev.ops&locale=en-U" return } }
17-Apr-2019 08:46
I apologize, I think I missed one of the problems I ran into with this. There is also a parameter in the URI that is randomly generated (i.e. &userID=sdfoajc391!90sjvdm3wdfs) so matching on a static URI wouldn't be possible.
17-Apr-2019 08:40
You may try with below:
when HTTP_REQUEST { if { ([string tolower [HTTP::uri]] equals "/ui/webconsole.html?vmId=ImAVM&vmName=DefinitelyALegitVM&host=vcenter222.dev.ops&locale=en-U") } { HTTP::redirect "https://[HTTP::host]/ui/webconsole.html?vmId=ImAVM&vmName=DefinitelyALegitVM&host=vcenter-server333.dev.ops&locale=en-U" return } }
17-Apr-2019 08:46
I apologize, I think I missed one of the problems I ran into with this. There is also a parameter in the URI that is randomly generated (i.e. &userID=sdfoajc391!90sjvdm3wdfs) so matching on a static URI wouldn't be possible.