Forum Discussion

Darrin_Wiens_25's avatar
Darrin_Wiens_25
Icon for Nimbostratus rankNimbostratus
Apr 29, 2008

Redirect to Multiple URLs

I am in the process of moving from a Cisco CSS to the F5 and I have an interesting Redirect issue. On the CSS, I have a content rule that has two services associated with it. Each service is of a redirect type and each goes to a different URL. Basically, it load balances two redirects. I need to do the same thing on the F5. I need to configure an iRule that will round-robin requests to two different redirects. Here is an example of what we've tried...

 

 

when HTTP_REQUEST {

 

HTTP::redirect "http://Server1/blah"

 

HTTP::redirect "http://Server2/blah"

 

}

 

 

Any ideas would be greatly appreciated.

 

 

Thanks,

 

Darrin

13 Replies

  • Posted By Colin on 05/09/2008 5:29 PM

     

     

    There isn't a good way that I can think of to do health-checks on remote sites. It's pretty easy to redirect users to wherever you want, but health-checking remote systems is a little more tricky.

     

     

    Colin

     

     

     

    I'm confused by this statement, Colin.

     

     

    What's the difference?

     

     

    If you setup a pool with a member that's remote (e.g. sample.domain.com) and setup a health monitor that performs 'GET /blah', surely this will do what the OP wanted...? mark the node down if the remote site doesn't respond to the GET /blah, thereby enabling the LB::status check.

     

     

    What am I missing?
  • Hi

     

    When sending the redirect back to the client, the client will initiate a new connection to a new destination. --> Server1 or Server2 Therefore no control over the connection within this irule anymore.

     

     

    I think you now found the issue, that you would not reach the server 1 or 2 if it is down.

     

     

    So i do not think you should work with redirect at all. Do you have control over those servers ?

     

    Why do you need to work with a redirect ? Just Loadbalance the Servers with a pool and replace the hostheader if needed. (don´t think you need to)

     

     

    Please explain us about the goal of the redirects a bit more that we are able to help

     

     

    Wiesmann

     

  • Here's a revision that avoids Global Variables so as to be CMP safe.

    when RULE_INIT {
      set static::redirect_targets {{https://www1.example.com/} {https://www2.example.com/} {https://www3.example.com/}}
    }
    
    when HTTP_REQUEST {
      HTTP::redirect [lindex $static::redirect_targets [expr {[table incr [virtual]_redirect_req_count] % [llength $static::redirect_targets]}]]
    }