Forum Discussion
TimRiker
Nov 15, 2019Cirrocumulus
We 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