Forum Discussion

Tom_B_90541's avatar
Tom_B_90541
Icon for Nimbostratus rankNimbostratus
Mar 26, 2012

irule too long

Greetings all. 9.4.X irule issue. We seem to have hit the character limit (KB SOL9204). Our irule looks like this:

 

 

when HTTP_REQUEST {

 

if {[HTTP::uri] starts_with "/test"} {pool pTest}

 

elseif {[HTTP::host] == "clienta.webdomain.com"} {pool pClienta}

 

elseif {[HTTP::host] == "clientb.webdomain.com"} {pool pClientb}

 

 

and it continues with a new "elseif" statement for each client. We have been able to free some space by removing a couple redundant or unnecessary lines, and that helps for the next week or so, but we need a long-term solution. I hope to avoid creating another virtual server. I have seen you can assign multiple irules to a virtual server, but I have not yet been successful in testing to get it to work. In a situation like the irule above, is it possible to have multiple irules? How would you make it work? Thanks in advance for any advice.
  • Hi Tom,

     

     

    The best option would be to move the hostname to pool name mappings to a data group. In 9.4.x you could use findclass to look up the requested host header in the data group and return the pool name.

     

     

    https://devcentral.f5.com/wiki/iRules.findclass.ashx

     

     

    A less ideal option would be to replace the if/elseif/elseif.../else chain with a switch statement. This should save you some characters in the iRule.

     

     

    https://devcentral.f5.com/wiki/iRules.switch.ashx

     

     

    Aaron
  • Thanks hoolio. I'll check these out and see which option may work best in my environment.