For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

RossVermette's avatar
RossVermette
Icon for Nimbostratus rankNimbostratus
Aug 11, 2016

iRule 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

  • Are you looking to simplify ? May be use a datagroup with the domains ?