Selecting a different node depending on URI

We are in the process of migrating services from an old Alteon load balancer to our F5 LTM 3900 (running 10.2.1). Most of the migrations have been successfully transferred as they were quite straightforward. One of the next ones is more complex however. There is a VIP on the Alteon with a single IP address and the end node (each with a different IP) is selected depending on the URI being requested, e.g. -

VIP = 1.2.3.4 Node 1 = 10.0.0.1 Node 2 = 10.0.0.2 etc. www.example1.com is sent to node 1 www.example2.com is sent to node 2 etc. What is the best way to achieve this on the F5 device? Thanks

you could use this irule (if node port is 80)

when HTTP_REQUEST {
  switch -glob [HTTP::host] {
    www.example1.com { node 10.0.0.1 80 }
    www.example2.com { node 10.0.0.2 80 }
  }
}

That looks pretty straightforward, thanks amolari.

You can do this with an iRule that selects a pool or pool member based on the HTTP host header. Something like this:

when HTTP_REQUEST {  
    switch [HTTP::host] {  
        "www.example1.com" { pool example-pool member 10.0.0.1 }  
        "www.example2.com" { pool example-pool member 10.0.0.2 }  
        default { pool example-pool}  
    }  
}

You can also do it with an If/elseif instead of a switch if you only have a couple of options.

You can do this with an iRule that selects a pool or pool member based on the HTTP host header. Something like this:

when HTTP_REQUEST {  
    switch [HTTP::host] {  
        "www.example1.com" { pool example-pool member 10.0.0.1 }  
        "www.example2.com" { pool example-pool member 10.0.0.2 }  
        default { pool example-pool}  
    }  
}

You can also do it with an If/elseif instead of a switch if you only have a couple of options.

There are over 50 possible different matches for this VIP so setting up a pool looks like a great idea. Thanks for your answer.

There are over 50 possible different matches for this VIP so setting up a pool looks like a great idea. Thanks for your answer.