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
- Born_7758NimbostratusI'm actually a little confused by that rule. I don't see where it looks at the requested URI and changes it to the new URI. By looking at the rule above, it looks like it's saying to match the requested URI against the data group and if it sees a match, then change the uri back to $uri....or maybe im just not getting it. Can you help me understand it?
- Colin_Walker_12Historic F5 AccountWell, after looking again it looks like the rule needs just a little updating. Try this:
when HTTP_REQUEST { set uri [findclass [HTTP::path] uri_class " "] if {$line ne ""}{ HTTP::uri $uri node 10.48.52.58 8080 } }
- Born_7758NimbostratusYes I think I understand now. Thank you very much for the explanation.
- Colin_Walker_12Historic F5 AccountExactly. :)
- Born_7758NimbostratusSweet!
- Colin_Walker_12Historic F5 AccountOf course! That should work just fine.
- Born_7758NimbostratusThank you for all of your help. I will test this and hope everything works. :)
- Colin_Walker_12Historic F5 AccountSure thing, let us know if you run into any trouble, or have any other questions.
- Born_7758NimbostratusI am using version 9.3.1. Would I still be able to use the findclass command, or should I use matchclass?
- Colin_Walker_12Historic F5 Accountfindclass should work just fine for you.
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