Forum Discussion

Pete_73764's avatar
Pete_73764
Icon for Nimbostratus rankNimbostratus
Jun 03, 2008

Website redirect

Is it possible to have an Irule inspect the header and redirect based on url? For example a request comes in for www.orange.com on a vip and gets directed to its pool, but another request for www.green.com comes in on the same vip but gets redirected to another vip.

4 Replies

  • If you have just a couple of pools for one virtual server, try something like this

     
     when HTTP_REQUEST { 
       if {[HTTP::host] equals {www.orange.com}} { 
         pool orangepool 
       } elseif {[HTTP::host] equals {www.green.com}} { 
         pool greenpool 
       } else { 
         pool other_or_no_host_header_to_this_pool 
       } 
     } 
     
  • A switch would also work nicely:

     
     when HTTP_REQUEST { 
      
         Select the pool based on the host header value 
        switch [string tolower [HTTP::host]] { 
           www.orange.com { 
              pool orangepool 
           } 
           www.green.com { 
              pool greenpool 
           } 
           default { 
              pool defaultpool 
           } 
        } 
     } 
     

    If you want to specify a VIP rather than a pool, you can use the 'virtual' command in 9.4 or later (Click here). Just replace pool POOL_NAME with vip VIP_NAME.

    Aaron
  • Is the VIP_NAME only in 9.4 or higher... I am running 9.3.1 and wanted something just like this for taking xyz.net to xyz.com, also I'd like to use this on a SSL VIP, so the request comes in on a SSL VIP will the traffic run through the iRule first or through the SSL first?

     

     

    Thanks

     

    Mello
  • Using the virtual command to select a new virtual server for the request is a feature added in 9.4. You'd need to upgrade to 9.4+ to use 'virtual' in this manner.

     

     

    Aaron