Skip to content

Instantly share code, notes, and snippets.

@fishnix
Created September 3, 2013 19:43
Show Gist options
  • Select an option

  • Save fishnix/6428611 to your computer and use it in GitHub Desktop.

Select an option

Save fishnix/6428611 to your computer and use it in GitHub Desktop.
ltm rule select_pool_by_host_and_uri {
when HTTP_REQUEST {
set url [substr [string tolower [HTTP::host]] 0 ":" ][string tolower [HTTP::uri]]
#log local0. "Saved url as $url"
# If we match exactly, get there fast
if { [class match $url equals yale_pool_selector] } {
pool [class match -value -- $url equals yale_pool_selector]
} else { # else loop through the data-group
set cn yale_pool_selector
set id [class startsearch $cn]
while { [class anymore $cn $id] } {
set n [class nextelement $cn $id]
set u [lindex $n 0]
set p [lindex $n 1]
if { ($url starts_with "$u/") }{
#log local0. "Matched url: $url with element [class nextelement -name $cn $id]"
pool $p
break
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment