Forum Discussion
Modify URI among other things
Here's what I am trying to do:
I have a datagroup called payment_resp_1
When I receive a request I want to match it to the URIs in the datagroup, modify it, and then forward it to a specific member in a pool.
Here is the contents of the datagroup:
/paymentresponse1.jsf
/paymenterror1.jsf
/paymentsuccess1.jsf
So if the HTTP request comes in as http://192.168.1.2:434/paymentresponse1.jsf I would like to modify it to /CSU/paymentresponse.jsf and forward it to a specific member in the pool, say for example 10.48.52.58.
and if it came in as http://192.168.1.2:434/paymenterror1.jsf I would like to modify it to /CSU/paymenterror.jsf and forward it the same way.
Here is an iRule that I wrote to start off. Can someone please take a look at it and let me know if I am in the right track and if possible supply a better solution.
when HTTP_REQUEST {
if {[matchclass [HTTP::uri] equals $::payment_resp_1]} {
HTTP::uri "/CSU/paymentresponse.jsf"
pool payment_resp member 10.48.52.58 8080
}
}
Thanks in advance
- hooleylistCirrostratusWhich LTM version are you running? Do you want to have an old URI, new URI and pool for each datagroup element?
- Born_7758NimbostratusI am running v9. I am not completely sure about what you are asking.
- Born_7758NimbostratusI wrote this iRule but I think there should be a more efficient way of doing it. This rule doesnt use a datagroup. I wanted to use a datagroup because I plan on creating a rule that will include other members in a pool and including different possible URIs.
- hooleylistCirrostratusFor 9.x you could create a string datagroup which has the following fields:
when HTTP_REQUEST { set line [findclass [HTTP::path] uri_class] if {$line ne ""}{ HTTP::uri [lindex $line 0] node [lindex $line 1] [lindex $line 2] } }
- hooleylistCirrostratusOr if you are using the same node address and port for all the entries in the datagroup, you could change leave that out of the datagroup:
when HTTP_REQUEST { set uri [findclass [HTTP::path] uri_class] if {$line ne ""}{ HTTP::uri $uri node 10.48.52.58 8080 } }
- Born_7758NimbostratusCan you please explain the following line?
if {$line ne ''''}
- Colin_Walker_12Historic F5 AccountIn his original example he was doing :
- Born_7758NimbostratusSo it should look like this?
- Born_7758NimbostratusSo it should look like this?
- Colin_Walker_12Historic F5 AccountYep, that looks right to me.
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com