Forum Discussion

anik3tdalvi_214's avatar
anik3tdalvi_214
Icon for Nimbostratus rankNimbostratus
Aug 24, 2015

iRule to load balance traffic based on directory

Hi all,

 

I am new to iRules and deploying a F5 solution which required traffic to be load balanced based on the directory structure. To give you an overview here's what the setup looks like this:

 

  • Single F5 VIP pointing to multiple pools (4 pools)
  • The pools are based on the directories they host
  • Pool members are same, however the service port is different

Here's my iRule

 

when HTTP_REQUEST { switch -glob [string tolower [HTTP::path]] { "/dir1"{ pool pool-1 } "/dir2"{ pool pool-1 } "/dir3"{ pool pool-1 } "/dir4"{ pool pool-2 } "/dir5"{ pool pool-2 } "/dir6"{ pool pool-3 } "/dir-a/dir-b*"{ pool pool-3 } } }

 

I'd like to know if the above rule is valid and if there's a better way of doing this. Any help will be appreciated.

 

1 Reply

  • it should be valid. What about the default pool (if no match)?

     

    You could achieve that also using LTM policies (instead of iRule), if you have a recent version of the BIG-IP software.