Forum Discussion

apache2020_5685's avatar
apache2020_5685
Icon for Nimbostratus rankNimbostratus
Aug 04, 2011

Redirect to different pools depending on requested URI

Hi

 

 

I am looking for an irule to forward traffic to different pools dependant on the DNS name requested by the client, so effectively the client requests any of the below which all map to the same vips:

 

 

- cat1.com/test.asp

 

- cat2.com/test.asp

 

- cat3.com/test.asp

 

 

depending on which URI is called it should forward to:

 

 

- pool1

 

- pool2

 

- pool3

 

 

Thanks for your help

 

 

David

5 Replies

  • Are you looking to redirect based on the /test.asp or on the actual DNS name catx.com?
  • See this thread, there are a couple examples of what you are lookig for.

     

     

    http://devcentral.f5.com/Community/GroupDetails/tabid/1082223/asg/50/aft/1177235/showtab/groupforums/Default.aspx
  • Hi

     

     

    I am looking to redirect based on dns name, all the example I can see are based on /test.asp etc
  • Hi

     

     

    I think I have found thebest way to do it, I presume this is also pretty efficent and then drops out to the default vserver pool if there is no match?

     

     

    when HTTP_REQUEST {

     

    switch [HTTP::host] {

     

    cat1.com {

     

    pool pool1

     

    }

     

    cat2.com {

     

    pool pool2

     

    }

     

    }

     

    }

     

     

    many thanks for your help, David
  • I'd try this to explicitly define which pool to use in all cases:

    when CLIENT_ACCEPTED {
    
        Save the name of the VS default pool
        before it can be modified in HTTP_REQUEST
       set default_pool [LB::server pool]
    }
    when HTTP_REQUEST {
       switch [string tolower [HTTP::host]] {
          cat1.com {
             pool pool1
          }
          cat2.com {
             pool pool2
          }
          default {
             pool $default_pool
          }
       }
    }
    

    Aaron