Forum Discussion
pzinsou_74089
Nimbostratus
Aug 29, 2007irule optimization - redirect based on URL
Hello, this is my irule.
I need to know how to optimize it. Is there any max number of "contains" conditions for the if. Or can I add many number of site to redirect?
Can I add many many site or should I have to create a data group list?
Thanks for your help.
when HTTP_REQUEST {
set Client_IP [clientside {IP::remote_addr}]
if { [IP::addr $Client_IP equals "141.227.1.2"] } {
log local0. "c'est le proxy1"
if { [HTTP::host] contains "yahoo" or [HTTP::host] contains "bred" } {
pool POOL_SURFING
log local0. "on utilise le pool POOL_SURFING"
} else {
pool POOL_ISP
log local0. "on utilise le pool ISP"
}
} else {
pool POOL_ISP
log local0. "on utilise le pool ISP"
}
}
- Your iRule is fine as long as your list of sites doesn't grow too large. There is no physical limit to the number of contains you can use, but by joining many "or" operators together in a single if statement, you'll eventually suffer a slight performance degredatation. Data Groups are one option and another option is to use a switch statement.
when HTTP_REQUEST { set Client_IP [clientside {IP::remote_addr}] if { [IP::addr $Client_IP equals "141.227.1.2"] } { log local0. "c'est le proxy1" switch -glob [HTTP::host] { "*yahoo*" - "*bred*" { pool POOL_SURFING log local0. "on utilise le pool POOL_SURFING" } default { pool POOL_ISP log local0. "on utilise le pool ISP" } } } else { pool POOL_ISP log local0. "on utilise le pool ISP" } }
http://devcentral.f5.com/wiki/default.aspx/iRules/HowToWriteFastRules.html
Click here - pzinsou_74089
Nimbostratus
Thanks Joe for your help,
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