iRule(s) using Data Group based on host and uri

So we are trying to implement single VIP (one Virtual IP) for multiple clients (websites) and would like to achieve that using iRules that has Data Group assigned. I was able to get the iRule working which has DG based on host. However I need to be able to accept certain requests based on couple of URIs as well. One of the URIs should work on port 80 and other on 85. Below is the iRule I have which works fine based on host for 443.

when HTTP_REQUEST {
  set pool [class match -value -- [HTTP::host] equals test_url]
  if {$pool ne ""} {
    pool $pool
   }
}

How do I append or add more iRules to manage my URI based traffic? I believe iRule for port 80 URI needs to be on 80_VIP. Also we need to have http to https redirect rule for everything other than above specified URI. URIs are as below --

/XYZ.svc* -- port 80

/example/attach/ABC.svc* -- port 85

URI (string) will be same for all clients but the pool (value) is different. So how do I get the request go to the right pool based on URI as well as host in the prefix? In my tests, all requests made for different client websites are going to the first pool in the data group.

You can attached all necessary iRule to the VIP in the Resources tab of the VIP. Just apply another iRules using the same way you applied the 1st iRule.

iRules will be executed in the order they applied.

Hi,

I have the scenario ,Loadbalancing based on the URI,

For example 1. to go one server pool under the VIP 2. to go to another server pool under the vip

/study and /sports are different URI

Could anyone please share the syntax of the irule to achieve this target

You can create your own. It is pretty simple. Use next URLs for examples

DevCentral - An F5 Technical Community DevCentral - An F5 Technical Community DevCentral - An F5 Technical Community

Share the code you created to see if there is any mistake