Forum Discussion

AaronB_8424's avatar
AaronB_8424
Historic F5 Account
Jun 04, 2008

Please review this iRule

Can somebody tell me why this iRule might not work properly? We are seeing urls that should match an else statement go to a different pool (not necessarily the fallback pool). Sometimes things work, sometimes it does not. Any suggestions would be most appreciated!

 

 

Here is the rule:

 

 

rule pleaseGetThisWorking {

 

when SERVER_CONNECTED {

 

log local0. "Node IP address: [IP::server_addr]"

 

}

 

when HTTP_REQUEST {

 

if { [HTTP::uri] contains "/securemail" } {

 

HTTP::redirect "https://someotherdomain.com/messenger/"

 

}

 

elseif { [HTTP::uri] contains "/test/" } {

 

use pool pilotweb

 

}

 

elseif { [HTTP::uri] contains "/Reporting" } {

 

use pool Reporting_Production

 

}

 

elseif { [HTTP::uri] contains "/raersWeb" } {

 

use pool reporting

 

}

 

elseif { [HTTP::uri] contains "/teleform/" } {

 

use pool reporting

 

}

 

elseif { [HTTP::uri] contains "UnblindUtility.jsp"} {

 

HTTP::redirect "https://www.MAINVIRTUALSERVER.com/unblind/transition/transition.htm"

 

}

 

elseif { [HTTP::uri] contains "/unblind/transition/" } {

 

use pool reporting

 

}

 

elseif { [HTTP::uri] contains "/unblind" } {

 

use pool reporting

 

}

 

elseif { [HTTP::uri] contains "/cews/" } {

 

use pool reporting

 

}

 

elseif { [HTTP::uri] contains "/wiki/" } {

 

use pool calgborgweb

 

}

 

elseif { [HTTP::uri] contains "/jira/" } {

 

use pool finback_jira

 

}

 

elseif { [HTTP::uri] contains "/sso/" } {

 

use pool sso

 

}

 

elseif { [HTTP::uri] contains "/devsso/" } {

 

use pool devsso

 

}

 

elseif { [HTTP::uri] contains "/testsso/" } {

 

use pool testsso

 

}

 

elseif { [HTTP::uri] contains "/betasso/" } {

 

use pool betasso

 

}

 

elseif { [HTTP::uri] contains "/rss/" } {

 

use pool baiji_rss

 

}

 

elseif { [HTTP::uri] contains "/rtp/" } {

 

use pool reporting

 

}

 

elseif { [HTTP::uri] contains "/statcenter/" } {

 

use pool calgb.org_web_servers

 

}

 

elseif { [HTTP::uri] contains "/qt" } {

 

use pool reporting

 

}

 

elseif { [HTTP::uri] contains "/reporting"} {

 

HTTP::redirect "https://www.MAINVIRTUALSERVER.org/Reporting"

 

}

 

else {

 

set uri [HTTP::uri]

 

set UA [HTTP::header "User-Agent"]

 

log local0. "lb fallthrough: $uri browser $UA"

 

use pool oracleweb

 

}

 

}

 

}

 

  • There is allot of IF-ELSEIF statements. It maybe more efficient to use the switch statement

    For example

          
         when HTTP_REQUEST {      
             switch -glob [HTTP::uri] {     
         "*/securemail*" { HTTP::redirect "https://someotherdomain.com/messenger/"  }     
         "*/test/*" { pool pilotweb }     
         "/raersWeb*" { pool Reporting_Production  }     
         "*"/teleform/*" { pool reporting }     
         .     
         .     
         .     
         DEFAULT {     
            set uri [HTTP::uri]      
            set UA [HTTP::header "User-Agent"]      
            log local0. "lb fallthrough: $uri browser $UA"      
            pool oracleweb      
         }     
             }     
         }        
         

    Click here and/or Click here for more indepth view of using the "switch" command

    Also if you have a default pool already assigned to the virtual address it will mean if non of these matches it basically picks the pool.

    Hope this helps

    CB

  • AaronB_8424's avatar
    AaronB_8424
    Historic F5 Account
    using the switch command is a good idea. When I get this rule to work properly I will try it.