Forum Discussion

steve_cross_650's avatar
steve_cross_650
Icon for Nimbostratus rankNimbostratus
Nov 14, 2006

NEWBIE: iRule for choosing pool based on URL

I am trying to point my subdomain towards a different pool of servers then my main site. For example:

www.mywebsite.com -> goes to pool a

beta.mywebsite.com -> goes to pool b

This is what i tried to use:


when HTTP_REQUEST { 
   if { [string tolower [HTTP::host]] equals "beta.mywebsite.com"}
   {
     pool pool_A
   }
   else
   {
     pool pool_B
   }
}

However nothing was ever routed to pool_A when i went to that URL. I even tried using a hard-coded URL so I would know when the iRule is going into effect:


when HTTP_REQUEST { 
   if { [string tolower [HTTP::host]] equals "beta.mywebsite.com"}
   {
   HTTP::redirect "http://www.google.com"
   }
   else
   {
     pool pool_B
   }
}

How can I figure out why my IF statement is failing? Would I be better using HTTP::host]] starts_with "beta."?

Again, I am a total newbie so maybe there is another setting that I don't have turned on which will make this iRule go "live". Any help would be GREATLY appreciated.

2 Replies

  • The rule looks fine. Just make sure that you have it associated with the VIP under the VIP's resources tab.

    You can add a log statement to determine the exact host and URI the client is requesting:

    
    when HTTP_REQUEST {
       log local0. "client: [IP::remote_addr] -> [HTTP::host][HTTP::uri]"
       if { [string tolower [HTTP::host]] equals "beta.mywebsite.com"}{
          pool pool_A
       }
       else {
          pool pool_B
       }
    }

    Aaron
  • Aaron,

     

     

    Thank you so much for your quick reply. You were correct! I had not yet associated my rule w/ a VIP. For other newbies out there who may have the same question I went to:

     

     

    Virtual Servers

     

    -> Clicked "edit" under the Resources column for my only HTTP VIP

     

    -> Clicked "manage" in the iRules section

     

    -> Moved my iRule from "available" to "enabled"

     

    -> Clicked "Finished"