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.
14 Replies
- lori_54451
Nimbostratus
here is the classi amusing for testing
class TURL_List {
"www.thermo.com/centrifugation http://www.thermo.com/cda/category/category_lp
/0,2152,53,00.html"
"www.thermo.com/histology http://www.thermo.com/com/cda/category/category_lp/
0,2152,211,00.html"
}
here is the irule
when HTTP_REQUEST {
set req "[HTTP::host]/[getfield [HTTP::uri] "/" 2]"
set redir [findclass $req $::TURL_List]
if {$redir !=""}{
HTTP::redirect $redir
}
}
when i hit www.thermo.com, i get this malformed http request
http://www.thermo.com/histology%20http://www.thermo.com/com/cda/category/category_lp/0,2152,211,00.html - Deb_Allen_18Historic F5 Accountah, yes, I omitted the separator character from the findclass command. Without it, the entire row is returned; with it, only the portion after the first separator is returned.
This should work better:
I also added a log line to assist in troubleshooting that logs the redirect value -- once you've got it working, delete that for production use.rule URIredirects { when HTTP_REQUEST { set req "[HTTP::host]/[getfield [HTTP::uri] "/" 2]" set redir [findclass $req $::myRedirects " "] if {$redir !=""}{ log local0. "Redirecting request for [HTTP::host][HTTP::uri] to $redir" HTTP::redirect $redir } } }
/d - lori_54451
Nimbostratus
Works like a charm. Thanks for all your help. We can re-commence the singing of songs of joy! - shawno_84086
Nimbostratus
Posted By deb on 05/02/2007 12:49 PM
oh, 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.
You can just browse in the GUI to Local Traffic/iRules, click on the Data Group List tab, and create a new list of type "String". Add your list, one row at a time, with a space separating the host/uri and the redirect (GUI will add the double quotes for you).
Class lists are stored in the bigip.conf file, and are loaded into memory with the rest of the config. We have customers using very large class lists with simple iRules such as this with minimal performance impact.
/deb
wow.. awesome post.. wish this was documented somewhere other than in the middle of a random thread
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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