Forum Discussion
Dan_Hughes_1946
Nimbostratus
Jan 06, 2010loadbalanced 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
Cirrostratus
Hi htran,
Yes, it sounds like this iRule would be a good start for your requirements.
Aaron - htran
Nimbostratus
Great. I will put it into test. Thank you. - WilliamP_113518
Nimbostratus
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
}
}
} - WilliamP_113518
Nimbostratus
great...the HTML didn't come through, how do I comment that out so it's not processed in the post?
William
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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