iRule to implement uri based redirection (v9.x)

iRule experts,

I am trying to implement an iRule that would basically do redirections based on the uri.

Pool1:

xxx.xxx.xxx.111:8000

xxx.xxx.xxx.222:8000

Pool2:

xxx.xxx.xxx.111:9000

xxx.xxx.xxx.222:9000

https://abc.com/business --> this should redirect to Pool1

https://abc.com/ --> this should redirect to Pool2

Thanks!

when HTTP_REQUEST {
  if { [HTTP::uri] starts_with "/business" } {
    pool pool_1
  } else {
    pool pool_2
  }
}

where “pool_1” and “pool_2” are the names of your respective pools.

Or, if you have the default pool set to pool_2 in your http profile, you could omit the else statement and just override the default for your /business requests

when HTTP_REQUEST {
  if { [HTTP::uri] starts_with "/business" } {
    pool pool_1
  }
}

PS, love the avatar!

-Joe

No problem and glad to help.

-Joe

Hi,

I have a similiar challenge. What I would like to do is have a https VIP using different certs based on URI.

Example:

IP: 10.123.123.1 = VIP

cert1 = www.abc.com > pool1

cert2 = test.abc.com > pool2

cert3 = www.cde.com > pool3

I would like to use irules to use different certs for different sites, and of course direct the traffic to the relevent pool.

Doesn’t work for HTTPS.

Short explanation here: DevCentral - An F5 Technical Community (Click here)

I’d suggest moving this request over to the iRules forum for better visibility.

-Joe

To clarify, since your question had 2 parts:

If you are terminating traffic @ LTM, you can distribute to different pools by hostname or URI.

However, you can’t choose a different cert because the info is received too late -- see above link for short explanation.