Forum Discussion
Jangle-Man_1290
Nimbostratus
Sep 19, 2014iRule - Direct traffic to specific pools based on host and URI
Good Afternoon,
I am struggling to find a winning combination for the following process.
The default Virtual Server pool is different and required for all other sites.
Step 1 - The website www....
Brent_West_7733
Sep 19, 2014Historic F5 Account
Maybe something like this would help?
when HTTP_REQUEST {
set debug 1
set client_info "[IP::client_addr]:[TCP::remote_port]: [HTTP::host][HTTP::uri]"
if { $debug } {
log local0. "$client_info requests [HTTP::host] and [HTTP::uri]"
}
if { [string tolower [HTTP::uri]] starts_with "/login" } {
if { $debug } { log local0. "$client_info - line 9 selected - pool is Pool_Admin_64" }
pool Pool_Admin_64
}
elseif { [string tolower [HTTP::uri]] starts_with "/lz/" } {
if { $debug } { log local0. "$client_info - line 14 selected - pool is Pool_Landing_64" }
pool Pool_Landing_64
}
elseif { [getfield [string tolower [HTTP::host]] ":" 1] eq "www.communigator.co.uk"} {
if { $debug } { log local0. "$client_info - line 19 selected - pool is Pool_Website" }
pool Pool_Website
}
else {
if { $debug } { log local0. "$client_info - line 24 selected - No Match, using default" }
}}
Brent_West_7733
Sep 19, 2014Historic F5 Account
The [HTTP::host] can look like www.example.com:80 which is why we need the getfield, and we would like our test to be case insensitive, hence the string tolower.
The [HTTP::uri] should be case insensitive, and I removed your wildcard, because string matches don't work that way. starts_with is sufficient.
I added 'elseif' because you usually want the iRule to stop processing conditionals after a pool selection is made, but in cases where there are multiple possible matches (a host and a uri) plan your logic accordingly. The last 'pool' statement wins.
After you get your iRule situated, remove the debugging statements unless you want them
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects