Forum Discussion

Haruto_Hashizum's avatar
Haruto_Hashizum
Icon for Nimbostratus rankNimbostratus
Nov 01, 2017

Where does this iRule end?

If client accsess the virtual server that has the iRule below with URI "/aaa/", which is the endpoint of this iRule A or B? I'm worried about that this rule excecute "LB::detach" .

when HTTP_REQUEST {
  switch -glob [string tolower [HTTP::uri]] {
     "*/aaa/*" {
        if { [active_members Pool_aaa] > 0 } {
        else {
           pool Pool_sorry
        }
   A→} 
     "*/bbb/*" {
        if { [active_members Pool_bbb] > 0 } {
        else {
           pool Pool_sorry
        }
     }
  LB::detach
  switch -glob [string tolower [HTTP::uri]] {
     "*/ccc/*" {
        if { [active_members Pool_ccc] > 0 } {
           if { [HTTP::cookie exists "CCC"] } {
              persist uie [HTTP::cookie "CCC"]
              pool Pool_ccc
           }
           else {
              pool Pool_ccc
           }
        }
        else {
           pool Pool_sorry
        }
     }
     default {
        if { [active_members Pool_default] > 0 } {
           pool Pool_default
        }
        else {
           pool Pool_sorry
        }
     }
 B→}

2 Replies

  • some curly brackets are missing. The Correct version of the iRule is below. This iRule always executes LB::detach command, after that, does the second switch command where it hits.

    when HTTP_REQUEST {
      switch -glob [string tolower [HTTP::uri]] {
         "*/aaa/*" {
            if { [active_members Pool_aaa] > 0 } {
            else {
               pool Pool_sorry
            }
          }
         }
         "*/bbb/*" {
            if { [active_members Pool_bbb] > 0 } {
            else {
               pool Pool_sorry
            }
         }
      }
      }
      LB::detach
      switch -glob [string tolower [HTTP::uri]] {
         "*/ccc/*" {
            if { [active_members Pool_ccc] > 0 } {
               if { [HTTP::cookie exists "CCC"] } {
                  persist uie [HTTP::cookie "CCC"]
                  pool Pool_ccc
               }
               else {
                  pool Pool_ccc
               }
            }
            else {
               pool Pool_sorry
            }
         }
         default {
            if { [active_members Pool_default] > 0 } {
               pool Pool_default
            }
            else {
               pool Pool_sorry
            }
         }
     }
     }
    
  • I would say that it ends here

     

    when HTTP_REQUEST {
      switch -glob [string tolower [HTTP::uri]] {
         "*/aaa/*" {
            if { [active_members Pool_aaa] > 0 } {
                pool Pool_aaa
                log local0. "Directing to pool_aaa"
            } else {
               pool Pool_sorry
               log local0. "Directing to pool_sorry"
            }
          }

    Though you can always add a logging command to your code and see which statement is hit