Using iRules to direct URL's to specific pools

I need help creating an irule. I have created a VS 10.10.100.5 (not actual VIP) that is listening on port 443, and created a pool (Pool name = CARS_AUTOS_POOL) with the server 10.10.100.190 listening on all ports. I was hoping I could use an irule to redirect the below URL to the correct server and listening port. For example, if a request from "; hits VIP 10.10.100.5 it will direct traffic to 10.10.100.190:4443. If "; hits VIP 10.10.100.5 it will direct traffic to 10.10.100.190:4445.

I’m brand new to irules and need some help getting start. Any help would be much appreciated. Thanks!

VIP configuration: SSL offloading and cookie persistence for 1 hour.

VS: 10.10.100.5:443 → to pool CARS_AUTOS_POOL (listening on all ports)

  1. https://lasrt.cars.auto.com/ → 10.10.100.190:4443
  2. https://lasrx.cars.auto.com/ → 10.10.100.190:4444
  3. https://lasru.cars.auto.com/ → 10.10.100.190:4445
  4. https://lasrd.cars.auto.com/ → 10.10.100.190:4446
  5. https://vision.cars.auto.com/ → 10.10.100.190:4447

There are quite a few ways to do this. One way is to use five pools, each with one pool member at the appropriate port address. (That way you’re not stuck with a pool member that can process traffic on any port.) So, lasrt_pool has pool member 10.10.100.190:4443, lasrx_pool has pool member 10.10.100.190:4444, and so on. Your iRule might look something like this:

when HTTP_REQUEST {
    switch -glob [string tolower [HTTP::host]] {
        "lasrt.cars.auto.com"  { pool lasrt_pool }
        "lasrx.cars.auto.com"  { pool lasrx_pool }
        "lasru.cars.auto.com"  { pool lasru_pool }
        "lasrd.cars.auto.com"  { pool lasrd_pool }
        "vision.cars.auto.com" { pool vision_pool }
    }
}
`
One scenario this doesn't deal with is if traffic arrives on the virtual server with a host that is something other than the five options defined above. You might want to include a default option that drops the connection (or does something else) if you get a different host. Also, if there's any chance someone might send a port number along with the host (e.g. lasrt.cars.auto.com:4443), you will need to take that into consideration by perhaps using if-elseif statements and "starts_with" (which you can't do with switch). For example:
`if { [string tolower [HTTP::host]] starts_with "lasrt.cars.auto.com" } {
    pool lasrt_pool
} elseif { [string tolower [HTTP::host]] starts_with "lasrx.cars.auto.com" } {....