Forum Discussion
RossVermette
Nimbostratus
Aug 11, 2016iRule help with HOST:header and URI path pool selection
I'm looking for a way to make maintaining/managing an existing iRule I have. I'm having a blank moment on trying to organize the HTTP host and uri path match logic. The iRule is similar to this:
Code when HTTP_REQUEST {
set pool_select_value [class lookup [string tolower [HTTP::host]] HOST_2_POOL_DG]
if {[active_members $pool_select_value] > 0 } {
log local0.notice "Available pool members in Pool: $pool_select_value"
switch [string tolower [HTTP::host]] {
"hostdev" -
"hostdev.domain.name" -
"hostdev.sub.domain.name" {
if uri is root then redirect to the subdirectory
switch [HTTP::uri] {
"/" { HTTP::redirect "/host-DEV/"
}
}
}
"host2sdev" -
"host2dev.domain.name" -
"host2dev.sub.domain.name" {
ir uri does not contain /name/ at the begining, insert name
switch -glob ![string tolower [HTTP::uri]] {
"/host2-services-dev/*" { HTTP::redirect "/host2-services-DEV[HTTP::uri]"
}
}
}
}
pool $pool_select_value
} else {
log local0.notice "NO Available members in Pool: $pool_select_value
set IFILE_RAW_ERROR_PAGE [ifile get "NoPoolMembers.html"]
set POOL_VAR_NAME_REPLACEMENT [list "pool_select_value" $pool_select_value]
set IFILE_FINAL_ERROR_PAGE [string map $POOL_VAR_NAME_REPLACEMENT $IFILE_RAW_ERROR_PAGE]
HTTP::respond 503 content $IFILE_FINAL_ERROR_PAGE
}
}I guess i'm looking for a method/ideas on using data groups to organize matches and appropriate responses. HELP!!!
1 Reply
- Vijay_E
Cirrus
Are you looking to simplify ? May be use a datagroup with the domains ?
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