Forum Discussion

Eduardo_Saito_1's avatar
Eduardo_Saito_1
Icon for Nimbostratus rankNimbostratus
Sep 13, 2007

Insane behaviour while selecting pool

Hello guys,

 

 

 

This week while troubleshooting an iRule made by another developer, an insane behaviour starded to happen.

 

 

The iRule is prety simple. The goal is to redirect to 3 pools (poolA, poolB and poolC) based on URI (eg. www.abc.com/uriA, uriB, and so on), and if none is matched, go to the default pool used by the Virtual Server.

 

 

The other goal is to remove the folder from the URI, so a request www.abc.com/uriA/test.html will look just as www.abc.com/test.html.

 

 

Here's the problem:

 

 

When you access www.abc.com/somethingelse/crazy.html, sometimes it goes to the default pool (working ok) and sometimes it goes to the poolA (wrong)!!!!

 

 

Even worst, on the webserver the uri looks unchanged. Which is crazy talk because if it is something wrong with the pool selection, it would at least remove the /somethingelse/ from it.

 

 

Here's the Problematic CODE:

 


   when HTTP_REQUEST {
      switch -glob [string tolower [HTTP::uri]] {
         "/uriA/*" {
            HTTP::uri [string range [HTTP::uri] 5 end]
            pool poolA
         }
         "/uriB/*" {
            HTTP::uri [string range [HTTP::uri] 5 end]
            pool poolB
         }
         "/uriC/*" {
            HTTP::uri [string range [HTTP::uri] 5 end]
            pool poolC
         }
      }
   }

 

 

Recently I've made the rule from the scratch and it seems working ok, but what was the problem with the original rule?

 

 

MyCode (THIS iRule Works OK - BUT WHAT'S THE PROBLEM WITH THE OLD CODE?):

 

 


when HTTP_REQUEST {
   set uri_original [string tolower [HTTP::uri]]
   if {$uri_original starts_with "/uriA/"}{
      HTTP::uri [string range [HTTP::uri] 5 end]
      pool poolA
   } elseif {$uri_original starts_with "/uriB/"}{
      HTTP::uri [string range [HTTP::uri] 5 end]
      pool poolB
   } elseif {$uri_original starts_with "/uriC/"}{
      HTTP::uri [string range [HTTP::uri] 5 end]
      pool poolC
   } else {
      pool default_pool_from_virtualserver
   }
}

4 Replies

  • There is no default condition on your switch statement:

    
    when HTTP_REQUEST {      
      switch -glob [string tolower [HTTP::uri]] {
             "/uriA/*" {
                HTTP::uri [string range [HTTP::uri] 5 end]
                pool poolA
             }
             "/uriB/*" {
                HTTP::uri [string range [HTTP::uri] 5 end]
                pool poolB
             }
             "/uriC/*" {
                HTTP::uri [string range [HTTP::uri] 5 end]
                pool poolC
             }
             default {
               pool default_pool_from_virtualserver
             }
          }
       }
  • hello citizen.

     

     

    First of all thanks for the reply.

     

     

     

    Yes. I did that and it does solve the problem too. But why didn't it used the default pool configured in the VS instead????

     

     

    Did I really need to specify it (default or the else at the end) even though the VS has the correct default POOL?

     

     

     

    Thanks Again
  • See this thread regarding your strange behavior:

     

     

    http://devcentral.f5.com/default.aspx?tabid=53&view=topic&forumid=5&postid=6751 Click here