Forum Discussion

Joanna_41630's avatar
Joanna_41630
Icon for Nimbostratus rankNimbostratus
Mar 07, 2013

iRule redirect and specify what Pool to go to

Hello -

 

 

I am trying to create an iRule to redirect "mypage.mycompany.com" to www.mypage.mycompany.com and also determine what pool it will be going to depending on the URI.

 

 

IF www.mysite.mycompany.com/ , www.mysite.mycompany.com or www.mysite.mycompany.com/sp* then it will go to go to mysite_http_pool

 

everything else will go to other_http_pool.

 

 

Not sure how to create this iRule any help is greatly appreciated.

 

 

Thanks,

 

 

Joanna

 

 

8 Replies

  • Hi Joanna,

    I'm assuming that you have more than one FQDN pointed to the same Virtual Server. In that case couldn't you do something like this...

     
     when HTTP_REQUEST {
    if { [HTTP::host] equals "www.mysite.mycompany.com" } {
    pool http_pool
    }
    else {
    pool some_other_pool
    }
    }
    

    Or do you just have one FQDN pointed to the site and you want to route totally based on the HTTP::uri?

  • Arie's avatar
    Arie
    Icon for Altostratus rankAltostratus

    Since you already have separate pools for the site instances, would it make sense to set up dedicated VIPs also? That way you'd avoid having to assign pools based on the host.

     

    Do you currently have a default pool? If so, you run the risk of taking down the other site(s) if the main pool doesn't have any healthy members.

     

  • Hello Michael -

     

     

    Yes I only have one FQDN pointed to the site and I want to be able to route based on the HTTP::uri.

     

     

    Thanks,

     

     

    Joanna

     

  • Arie's avatar
    Arie
    Icon for Altostratus rankAltostratus

    It sounds like you have two FQDNs going to the VIP: "mypage.mycompany.com" and "www.mypage.mycompany.com". From your description it looks like you want the iRule to do two things:

     

    1. Redirect all traffic from "mypage.mycompany.com" to "www.mypage.mycompany.com".
    2. Select the pool "mysite_http_pool if the client requests the home page or if the path starts with "sp", and select "other_http_pool" for all other requests.

    Couple of questions/remarks:

     

    1. Do clients ever go to the home page by including the file name (e.g. "www.mypage.mycompany.com/index.html")? If so, what is the file name of the default page (e.g. "index.html")?
    2. Which pool will be the default pool on the VIP?
    3. Will it be a problem if the default pool takes down the VIP (since the other pool might still be healthy)?
  • Hello Arie -

     

    Yes you are correct, that is exactly what I am trying to accomplish with the iRule. To answer your questions:

     

    1. Client should not be able to get to the homepage by including the filename unless they bookmark the page.

     

    2 and 3 - I was not going to setup a default pool, I was just going to let the iRule make the decision - do you think I need to have a default pool.

     

    This is an iRule that the web team suggested, I am getting syntax errors so I'm playing around with it to see if i can get it to work.

     

    when HTTP_REQUEST {

     

    Redirect non www traffic to www

     

    if {

     

    ([HTTP::host] starts_with "mypage.mycompany.com")

     

    }

     

    {

     

    HTTP::redirect ]

     

    }

     

    Send home page to sharepoint pool

     

    elseif {

     

    ([HTTP::uri] matches "/") || ([HTTP::uri]matches "")

     

    }

     

    {

     

    HTTP::redirect http://www.mypage.mycompany.com/sp/

     

    }

     

    Send any traffic with sp to the sharepoint pool

     

    else if {

     

    ([HTTP::uri] starts_with "/sp/") || ([HTTP::uri] matches "/sp")

     

    }

     

    {

     

    pool sp_http_pool

     

    }

     

    Send any other traffic to sun java webserver pool

     

    else

     

    {

     

    pool sunjava_http_pool

     

    }

     

    }

     

     

    Any help is greatly appreciated.

     

     

    Joanna

     

  • Arie's avatar
    Arie
    Icon for Altostratus rankAltostratus
    1)

    OK. Just be mindful that a postback on the page would expose the filename of the page, which users may bookmark.

    2/3)

    If you don't have a default pool you will not have any health information available for that VIP. If you do have a default pool the entire VIP will be taken down if the default pool goes down.

    Are you using SSL or planning to use it in the future? If so you'll want to set up dedicated VIPs.

    As far as your iRule error go, they're caused by an invalid "elseif" syntax. Firstly, you can't have comments between the closing curly brace and the "elseif" command. Secondly, the "elseif" command needs to immediately follow the curly brace:

    } elseif {
  • Arie's avatar
    Arie
    Icon for Altostratus rankAltostratus
    1)

    OK. Just be mindful that a postback on the page would expose the filename of the page, which users may bookmark.

    2/3)

    If you don't have a default pool you will not have any health information available for that VIP. If you do have a default pool the entire VIP will be taken down if the default pool goes down.

    Are you using SSL or planning to use it in the future? If so you'll want to set up dedicated VIPs.

    As far as your iRule error go, they're caused by an invalid "elseif" syntax. Firstly, you can't have comments between the closing curly brace and the "elseif" command. Secondly, the "elseif" command needs to immediately follow the curly brace:

    } elseif {
  • Arie - thanks for the help on the syntax I didn't know this. I was able to put in the code without any syntax error; the webteam is testing to see if we get the results they are looking for (looks promising).. To answer your question to number 2, we are not planning on using SSL (at least for now) and I did warn them that if in the future they wanted to use SSL we would have to use dedicated VIPs which their response was that this was only a temp rule until they migrated everything from our sun web servers to our sharepoint. Thanks for your help.

     

     

    Joanna