For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

Dan_Hughes_1946's avatar
Dan_Hughes_1946
Icon for Nimbostratus rankNimbostratus
Jan 06, 2010

loadbalanced redirection

Howdy,

 

 

Wondering if anyone can suggest a solution to a little problem I have. I want traffic coming into an LTM to be redirected to one of two URLs - based on a round robin loadbanace. So :

 

 

client sends request to www.domain.com

 

 

LTM returns HTTP redirect to either firsthost.domain.com or secondhost.domain.com based on a round robin loadbalance..

 

 

I can see lots of ways of returning a single redirect in a given set of circumstances, and I see of course simple ways to proxy/forward to a pool of servers. But I can't see an obvious method of load balancing to multiple redirects.

 

 

Any help appreciated!

 

 

Dan

 

14 Replies

  • hoolio's avatar
    hoolio
    Icon for Cirrostratus rankCirrostratus
    Hi htran,

     

     

    Yes, it sounds like this iRule would be a good start for your requirements.

     

     

    Aaron
  • Hi all, I dug up this old thread searching for information on a project I've been working on. I was in the LTM Advanced class and the instructor had a cool setup in the LTM's in class that simulated the web servers on the LTM devices themselves. So I wanted to do that here on my laptop, where my virtual environment isn't as robust as a larger ESX environment or physical boxes.

     

     

    So...I wanted to have the LTM respond to HTTP and HTTPS traffic whenever a client request hit it, without having to pass it off to a pool or pool members.

     

     

    I used a mixture of the example above, and another couple bits I found elsewhere to get the following. This works at this point, but I was wondering if there is a way to get this to work for more than two servers. I tried just adding another to the list of items, and having the last one set the redirect_counter to 0 again, but then the system hangs after it reaches the second server, meaning it no longer refreshes whenever I hit CTRL+F5 or just the reload option. Please let me know if what I'm trying to do doesn't make sense.

     

     

    Also, someone told me once that you want to minimize the amount of white pace in an iRule to speed up processing. Thus I put all the HTML on one line. Could you point me in the right direction to understand why this is, and how I can make sure I'm starting off with good coding habits with iRules rather than bad ones?

     

     

    Thanks, and here is what I have:

     

     

    when RULE_INIT {

     

     

    Initialize the redirect counter to 0

     

    set ::redirect_counter 0

     

    }

     

    when HTTP_REQUEST {

     

     

    Check the counter value

     

    switch $::redirect_counter {

     

    0 {

     

    Value was 0, respond with webpage from 1st server

     

    HTTP::respond 200 content {

     

    WebServer1Welcome to the ISCSI Test Lab! You are on Server 1 }

     

    set ::redirect_counter 1

     

    }

     

    1 {

     

    Value was 1, respond with webpage from 2nd server

     

    HTTP::respond 200 content {

     

    WebServer2Welcome to the ISCSI Test Lab! You are on Server 2 }

     

    set ::redirect_counter 0

     

    }

     

    }

     

    }
  • great...the HTML didn't come through, how do I comment that out so it's not processed in the post?

     

     

    William