Forum Discussion
lori_54451
Nimbostratus
May 01, 2007Using iruel for redirects
I just inherited a web hosting farm that is experencing issues contolling thier targeted urls within thier web application. They have been living with this issue in thier previous hosting site for 2-3 years I suggested we use the bigip to perform these targeted url redirects. We already successfully use iRules to do redirects for all of our ecommerce websites, seems like a good fit. We were all busy singing joyous songs of celebration when they dropped the bomb! They have almost 600 targeted urls. The most if/else url inspections I do currently in a single iRule is 15. So, my question is simply, what should I be thinking about if i'm going to build an iRule that has 600 url inspection lines in it.
- Deb_Allen_18Historic F5 AccountPlease, by all means, continue singing, and let's all think happy thoughts about the "findclass" command...
- lori_54451
Nimbostratus
This is the current rule that i am testing, - Deb_Allen_18Historic F5 AccountWell, I'm sort of trying to edge you away from the "death by 600 if's" version of the iRule you could create... but to do so, we'll need to know if the decision will always be based on the hostname and first directory, as in the example you give above, or will there be some variation in what needs to be evaluated -- different hostnames, different of directories, etc.
- lori_54451
Nimbostratus
always based on hostname and 1st directory. - Deb_Allen_18Historic F5 AccountSure, then, that's pretty straightforward:
Then create this iRule an apply to the virtual server:class myRedirects { "www.thermo.com/histology http://www.thermo.com/.../0,2152,53,00.html" "www.whatever.com/dir1 http://newhost/newuri" }
rule URIredirects { when HTTP_REQUEST { set req "[HTTP::host]/[getfield [HTTP::uri] "/" 2]" set redir [findclass $req $::myRedirects] if {$redir !=""}{ HTTP::redirect $redir } } }
- lori_54451
Nimbostratus
Thats pretty sweet. Is the class list stored in memory, do i need to worry about memory consumption - lori_54451
Nimbostratus
stupid question, hpw do i create the class list. I read some doc, looks like i need the webacclerator module, which i do not have - Deb_Allen_18Historic F5 Accountoh, sorry, they are still called classes in the config, but I keep forgetting they are now called "Data Group Lists" in the GUI and doc.
- lori_54451
Nimbostratus
thanks. is there a trick to adding the 600 or so strings, besides hand editing the conf file..? - Deb_Allen_18Historic F5 AccountYou can edit the config file, in which case you'd need to just follow this format:
Once the conf file is saved, load into memory with a manual config reload ("bigpipe load" at the command line). Once the class is created, indivudual members can be updated on the fly in the GUI.class myRedirects { "hydration.company.com http://www2.co.com/hydration.html" "nhra.com http://www.us.company.com/nhraHome.do" "redirect.co.com http://www.company.com/" "thecompany.com http://www.thecompany.com/" }
and create a class of type "External" referencing this file. Note the trailing comma on each line, including the last. Changes to the file require a manual config reload before they take effect ("bigpipe load" at the command line)."hydration.company.com http://www2.co.com/hydration.html", "home.company.com http://www.us.company.com/Home.do", "redirect.co.com http://www.company.com/", "thecompany.com http://www.thecompany.com/",
Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects