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

Dave_21103's avatar
Dave_21103
Icon for Nimbostratus rankNimbostratus
May 16, 2014

iRule for URI Switching Nested Inside of Hostname Switching

Is it possible to nest URI switching inside hostname switching? If so, does someone have any links or suggestions I can try? I found a hostname switching example (below, after uri example). However, instead of switching to a pool, i would like the irule to switch to code that URI switches. Instead of "pool site1_pool" in the hostname switching example below, I would like to know if you can replace "pool site1_pool" with something similar to this:

 

URI switching example

when HTTP_REQUEST {

 

switch -glob [string tolower [HTTP::uri] ] {

 

"/path1/file.jpg" { pool POOLNAME1 }

 

"/path2/file.jpg" { pool POOLNAME2 }

 

default { drop } } }

 

hostname switching example

when HTTP_REQUEST {

 

 Check requested host header (set to lowercase) 
switch [string tolower [HTTP::host]] { 

   "www.site1.com" { 
      pool site1_pool 
   } 
   "www.site2.com" { 
      pool site2_pool 
   } 
   default { 
      pool default_pool 
   } 
} 

}

 

3 Replies

  • Absolutely possible.

    when HTTP_REQUEST {
        switch [string tolower [HTTP::host]] {
            "www.domain.com" {
                switch -glob [string tolower [HTTP::uri]] {
                    "/app1*" { log local0. "app1" }
                    "/app2*" { log local0. "app2" }
                    "/app3*" { log local0. "app3" }
                    default { drop }
                }
            }
            default {
                drop
            }
        }
    }