Forum Discussion
iRule switch pool based on URI
BootsHasDrugs Would you be able to provide a bit more detail on exatly what you are attempting to do? The reason I ask is because the iRule seems sound with the exception of where you are defining the default pool and what mechanism you are using to define the default pool. I would configure the default pool as the pool associated to the virtual server and then define the pool using a slightly different command. Also, if you might consider creating a /32 OneConnect profile and assigning it to the virtual server so that it then performs a HOST and URI check per HTTP request rather than just on the initial HTTP request. I have also added some changes that use the following style guide.
https://community.f5.com/t5/technical-articles/irules-style-guide/ta-p/305921
The following should be how the iRule should look based on my comments.
when CLIENT_ACCEPTED priority 500 {
set DEFAULT_POOL [LB::server pool]
}
when HTTP_REQUEST priority 500 {
# Static variables
set non_default_pool "sample-site.com-NON-DEFAULT"
set hostlist [list sample-site.com]
if { [lsearch $hostlist [string tolower [HTTP::host]]] ne -1 } {
switch -glob [string tolower [HTTP::uri]] {
"/non-default-page/" -
"/non-default-page/*" {
pool ${non_default_pool}
}
default {
pool ${DEFAULT_POOL}
}
}
}
}
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com