Here's an iRule I use for this type of thing. It uses a "Datagroup" that you can update the http host header to pool mapping to do what you want.
-
Create a Datagroup "HOST_2_POOL_DataGroup" with entries like:
"expample.com" := "APP_Pool01",
"subdomain.example.com" := "APP_Pool02",
`
-
Here is the iRule "HTTP-Host-2-Pool-MAP"
`when HTTP_REQUEST {
set pool_select_value [class lookup [string tolower [HTTP::host]] HOST_2_POOL_DataGroup]
if {[active_members $pool_select_value] > 0 } {
log local0.notice "available pool members"
pool $pool_select_value
} else {
HTTP::respond 503 content "No active pool members in pool"
}
}