Forum Discussion
Refine iRule with external class file
I have created an iRule where I pick which servers are used based off URI. IE. if www.mysite.ca/principal go to webnode and if www.mysite.ca/it go to drupal.
One thing I am having trouble with is the format of the external file. does anyone know how to write the rule so that only the excact match to the file is sent. Certain sites start similar , such /it and /italian. Wondering how the file can be written to pick the exact phrase I specify?
The iRule in place is
when HTTP_REQUEST {
if { [class match [HTTP::uri] starts_with DRUPALSITES] } {
pool DRUPAL
} else {
pool WEBNODE }
}
The External File looks like:
/eas,
/esaac,
/economics,
/edtech,
/efchr-events,
/emergency,
/emf,
etc.
I did try /eas/, and that works most of the time but certain sites would break. In this format, most sites append the / ; while others do not, and then i need to manually add the /
So I have opted not to have any trailing /
Anyone deal with a problem like this???
Thanks
- Michael_YatesNimbostratusReview this post. It should help you with the information that you need.
- One thing I am having trouble with is the format of the external file. does anyone know how to write the rule so that only the exact match to the file is sent. Certain sites start similar , such /it and /italian. Wondering how the file can be written to pick the exact phrase I specify?
- chungyu_16122AltostratusThanks alot for the tips, I am going to look at the links.
- chungyu_16122AltostratusI have tried the equals operator but still having problems , I think it is the way the external file is written. I just used a nano and created a list of files
- Ryan_Paras_7933NimbostratusIf you are willing to switch from an external file to class/datagroup, I think the code I posted here: http://devcentral.f5.com/Forums/tabid/53/aft/1179378/Default.aspx at "07/06/2011 11:27 PM" may be able help you accomplish what you are looking to do.
- Cosnatelnu_1754NimbostratusI agree, it does sound a bit like a 'quick fix' solution.Surely you can never be 100% absolutely certain that something won't go wrong.
- chungyu_16122Altostratus
Thanks guys
we have refined the rule a bit , this works for the most part but I need to maintain 2 list, one for webnode and one for drupal nodes.
when HTTP_REQUEST {
I did follow your post and found some interesting info which may us help refine this even more.
- If your goal is to maintain one class, research the findstr command.
- chungyu_16122AltostratusWorking with one of our web programmers we found the right combination of iRule.
Thanks
when HTTP_REQUEST {
set SITE [lindex [split [string tolower [HTTP::uri]] "/"] 1]
if {[matchclass $SITE equals $::DRUPALSITES]}{
pool DRUPAL
}
elseif {[matchclass $SITE equals $::WPS2]}{
pool WEBNODE
}
else {
log local0. "Requested URL does not match any class: [HTTP::uri], defaulting to pool WEBNODE"
pool WEBNODE
}
}
The biggest problem I found was the external file format, although there are many examples no are specific on how the structure interacts with the iRule
using nano editor
"word", is what I need for the equals variable.
"/word," is fine for contains or starts_with variable.
"word":="key1" which is the b class format works but no one at F5 support could explain the the "key1" variable. And honestly, it is faster for me just to use the nano editor vs the b class format.
Thanks for everyone's help.
Chung
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