Forum Discussion

Blake_Traister2's avatar
Blake_Traister2
Icon for Nimbostratus rankNimbostratus
Apr 08, 2009

Choose pool based on URL (filename extension)

I have built 3 pools and need to choose the pool on the following criteria:

 

 

Port Redirection

 

IF (URL == /.asp) || (URL == /.css) || (URL == /.aspjs) || (URL == /.htc) || (URL == /.aspxml) || (URL == /.aspxsl) || (URL == /*.html)

 

GOTO port 6002

 

IF (URL == /*.svc)

 

GOTO port 7006

 

IF NONE OF THE ABOVE

 

GOTO Port 6102

 

 

My Irule which seems VERY ugly to me:

 

 

when HTTP_REQUEST {

 

if {[HTTP::uri] contains ".asp"} {

 

pool stage.cmr.yellowpages.com_6002

 

} elseif {[HTTP::uri] contains ".css"} {

 

pool stage.cmr.yellowpages.com_6002

 

} elseif {[HTTP::uri] contains ".aspjs"} {

 

pool stage.cmr.yellowpages.com_6002

 

} elseif {[HTTP::uri] contains ".htc"} {

 

pool stage.cmr.yellowpages.com_6002

 

} elseif {[HTTP::uri] contains ".aspxml"} {

 

pool stage.cmr.yellowpages.com_6002

 

} elseif {[HTTP::uri] contains ".aspxsl"} {

 

pool stage.cmr.yellowpages.com_6002

 

} elseif {[HTTP::uri] contains ".html"} {

 

pool stage.cmr.yellowpages.com_6002

 

} elseif {[HTTP::uri] contains ".svc"} {

 

pool stage.cmr.yellowpages.com_7006

 

} else {

 

pool stage.cmr.yellowpages.com

 

return

 

}

 

log local0.info

 

}

 

 

Additionally, I would like to redirect to a different VIP if all 3 pools are down...

1 Reply

  • c_p_i_o_17707's avatar
    c_p_i_o_17707
    Historic F5 Account
    1. You can use a "switch" statement to instead of "if/else" to make it cleaner. It seems like 6002 pool would probably be under the default statement.

     

    2. You can make use of the "LB::Status" command to redirect to a different "pool" if all 3 pools are down.

     

    OR

     

    3. You can use "HTTP::redirect" if it makes sense in your env.