Forum Discussion
cdsmimth
Altostratus
Nov 13, 2019iRule for handling traffic to multiple pools through the same VS
I tried searching for questions asked by people trying to do substantially the same thing I am and came up close ... but empty. I'm hoping someone here can help me out a bit. Here's the set-up: ...
TimRiker
Cirrocumulus
Nov 15, 2019We use an iRule and a datagroup to route different host/[path] to pools in the same iRule. Here's some example code:
set log(search) $host[string tolower [HTTP::uri]]
set pool [class match -value $log(search) starts_with dg_shared.example.com]
if { $pool ne ""} {
set matched [class match -name $log(search) starts_with dg_shared.example.com]
set log(matched) $matched
set log(pool) $pool
if { $pool starts_with "http" } {
# datagroup entry is realy a redirect
set log(reason) "redirect"
call hsllog log
HTTP::respond 307 Connection Close Location $pool Virtual-Name [virtual name]
TCP::close
event disable
return
} elseif { [catch { pool $pool } ] } {
set log(reason) "Failed to Connect to Pool"
call hsllog log
call errorpage 404 $log(reason) "https://[HTTP::host][HTTP::uri]" log
}
} else {
call errorpage 404 "No Pool Found" "https://[HTTP::host][HTTP::uri]" log
}this uses starts_with so datagroup entries would look like:
test.example.com/ := https://test.example.com/tool-two
test.example.com/tool-one := pool_one
test.example.com/tool-two := pool_two
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