Forum Discussion
Darrin_Wiens_25
Nimbostratus
Apr 29, 2008Redirect 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
- This should work for you.
when RULE_INIT { set ::whichone 0 } when HTTP_REQUEST { switch $::whichone { 0 { HTTP::redirect "http://Server1/blah" } 1 { HTTP::redirect "http://Server2/blah" } } set ::whichone [expr ! $::whichone] }
when RULE_INIT { set ::whichone 0 } when HTTP_REQUEST { switch $::whichone { 0 { HTTP::redirect "http://Server1/blah" set ::whichone 1 } default { HTTP::redirect "http://Server2/blah" set ::whichone 0 } } }
- Darrin_Wiens_25
Nimbostratus
Joe - Thanks for the quick response. We are gettign ready to throw that in now. I'll let you know tomorrow if it worked. - Darrin_Wiens_25
Nimbostratus
Joe, - Darrin_Wiens_25
Nimbostratus
So I have another piece I was just asked to address with this. Is there a way to do a health check of the site I'm redirecting to prior to sending the client there? Something like.... - JRahm
Admin
If you have that site defined as a pool member (you can add as a dummy host), then you can use the LB::status command as a conditional before redirecting. Here's the wiki page for the LB commands: - Darrin_Wiens_25
Nimbostratus
Can you have a redirect site as a pool member? How do you create a dummy host? - Darrin_Wiens_25
Nimbostratus
What Joe gave me above works perfectly, but I'd like to add one more piece to that. So I want the iRule to redirect to two different sites and technically load balance them which is what Joe's code does. But now I'm curious if, before it sends the user to the redirect site, can the iRule do a health check of that site and if it's down, send the user to the other redirect site. - JRahm
Admin
Look three posts up the thread... - Darrin_Wiens_25
Nimbostratus
I can't define sample.domain.com/blah as a node or a pool member. I can do sample.domain.com. I'm trying to redirect to another site and a page on that site. - Colin_Walker_12Historic F5 AccountThere 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.
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects