Forum Discussion

Les_Marstaeller's avatar
Les_Marstaeller
Icon for Nimbostratus rankNimbostratus
Dec 15, 2005

Default pool when using IRules

Hi,

 

 

I am using an irule to direct http requests to one of two pools depending on the url.

 

 

eg. /123 goes to pool 123 and /456 goes to pool 456

 

 

In this case, do I need to set a default pool for the virtual server? If so, which one?

 

 

Thanks for any help,

 

 

Les

 

Canberra, Australia.

7 Replies

  • You don't need a default pool in this situation, you could have your iRule redirect to a generic page if you wanted a "catch everything else" set-up.

    Something like this would work

    
    when HTTP_REQUEST {
      if {[HTTP::uri] starts_with "/123"} {
        pool 123
      } elseif {[HTTP::uri] starts_with "/456"} {
        pool 456
      } else {
        HTTP::redirect http://some.other.address/
      }
    }

  • unRuleY_95363's avatar
    unRuleY_95363
    Historic F5 Account
    I will add merely one thing. The status of the virtual is derived from the status of the default pool. Without no default pool, your virtual server status will appear blue - or unknown. Other than that, there is no need for the default pool.
  • Great, thanks very much for your help.

     

     

    A merry & safe Christmas to everyone,

     

     

    Les
  • One further question..

     

     

    When I use "elseif" in the irule, it comes up with an error "Unknown Procedure". Any clues why this might be happening? We are using version 9.2

     

     

    Thanks,

     

     

    Les
  • Can you post the code that's generating the error?

     

     

    Generally, you need to form your code like this

     

     

    if { condition } {
       do_something
    } elseif { condition2 } {
       do_something_else
    } else {
       do_something_different
    }

     

     

    If you put a space after a brace and then the elseif on a newline, it can cause validation errors.

     

     

    -Joe
  • unRuleY_95363's avatar
    unRuleY_95363
    Historic F5 Account
    You may be bumping into the infamous space after the "} " when the "elseif" is on a new line problem. Tcl actually requires the "elseif" to be on the same line as the closing bracket, like Joe's example above. However, we extended Tcl to allow elseif to begin on a newline, but due to implementation details, it doesn't work if there is a trailing whitespace and thus thinks the "elseif" is an undefined command/procedure.
  • Thanks once again for all your help. It is great to know that such knowledgable and helpful people here when I need it.

     

     

    A happy holiday to you all.

     

     

    Les

     

    Canberra, Australia.