Forum Discussion

Gill_32697's avatar
Gill_32697
Icon for Nimbostratus rankNimbostratus
Oct 23, 2012

Need redirect irule help please !

I need a redirest irule, I can not use http class.

 

The developer only want the irule to act on the specifc uri path and send to pool1, any other uri path or no uri path at all goes to pool2.

 

http://test-swbc.com/akcelerant/

 

http://test-swbc.com/idsakcelerant/

 

http://test-swbc.com/idsakcelerantmtg/

 

http://test-swbc.com/lmakcelerant/

 

Vip: 10.200.1.62

 

Pool1 node: 10.16.5.50

 

Pool2 node: 10.25.25.100

 

Im lookiing for the I irule to use the if and else statements so that I can add more uri's as needed.

 

I'm not good a scripting so i realy need a completed irule that I can just paste with little editing. I can adjust the

 

nodes and uri's but the structure needs to be there compete. I not good at adding the brackets and quotes.

 

 

Thank you.

 

 

  • Correct, add another line after the first one. THe new line would look like

     

     

    "/newuri/" -

     

     

    and yes, it should match only the uri's as specified. Actually, it will be case-insenstive, so it would match the uri list no matter what combination of upper and lowercase characters. If you do not want that and only want it to match on lower case, then change the switch statement to:

     

     

    switch -glob [HTTP::path]

     

  • Here is how I do it.

     

     

    ------------------------------

     

    when HTTP_REQUEST {

     

     

    use tolower to make the match case-insensitive

     

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

     

     

    "/akcelerant/" -

     

    "/idsakcelerant/" -

     

    "/idsakcelerantmtg/" -

     

    "/lmakcelerant/" {

     

    pool pool1

     

    }

     

     

    default {

     

    pool pool2

     

    }

     

    }

     

    }

     

    ----------------------------------------

     

     

    If you want all sub-uri's below the specified uri's to go to pool1 as well, then add a * at the end of each one, like "/akcelerant/*".

     

  • Ok so if I need to add more uri path I could insert after first one..correct?

     

    so this will match only the ones defined here otherwise pool2..correct?

     

     

    Thank you very much Pconlan
  • Correct, add another line after the first one. THe new line would look like

     

     

    "/newuri/" -

     

     

    and yes, it should match only the uri's as specified. Actually, it will be case-insenstive, so it would match the uri list no matter what combination of upper and lowercase characters. If you do not want that and only want it to match on lower case, then change the switch statement to:

     

     

    switch -glob [HTTP::path]