Forum Discussion
host header load-balancing
Hi,
I'm having a question on host-header load balancing, or something similar. To be more specific, I have a conditional irule where the pools listen to different URL's.
This is what I have at this moment :
when HTTP_REQUEST {
switch -glob [HTTP::header value "User-Agent"] {
"*MSIE 6*" -
"*MSIE 7*" -
"*MSIE 8*" {
pool site-10.130.14.98_9610
}
default {
pool site-10.130.14.98_29710
}
}
}
The problem is that this pool site-10.130.14.98_9610 is actually only giving correct output on msie.foo.com/login/ and site-10.130.14.98_29710 listens to listening www.foo.com Basically, if I could add the /login to site-10.130.14.98_9610, that would do the trick as well, as only the /login is important. The default pool works fine.
Thank you,
Hans
10 Replies
- Your included irule is relating to User-Agent, not a specific URL.
- Colin_Walker_12Historic F5 Account
So what it sounds like you need is to balance based on URI first, and then User-Agent after that. I.E. if the user is accessing msie.foo.com/login, then decide where to route things based on their User-Agent. Otherwise, send everything to the default pool, since it is the one that is set up to handle all of foo.com. Does that sound correct?
If so, you're awfully close, and just need to add another conditional. Try this:
when HTTP_REQUEST { switch -glob [HTTP::header value "User-Agent"] { "_MSIE 6_" - "_MSIE 7" - "_MSIE 8" { if {[HTTP::uri] eq "/login"} { pool site-10.130.14.98_9610 } else { pool site-10.130.14.98_29710 } } default { pool site-10.130.14.98_29710 } } }
- htuytela_37346
Nimbostratus
Hi Colin, thank you for your reply. Basically, let me clarify some more. My problem is that I have 2 backend web servers that listen on different FQDN's, and that I need to redirect based on browser-type. So the URL, pointing to the F5, is www.foo.com. When IE used, the user is redirected to pool site-10.130.14.98_9610, but that server needs to suffix /login to give a valid response, so he is only listening to www.foo.com/login. The default server is listening www.foo.com. At this moment, the redirect based on IE works, but since the wrong FQDN is used, the users does not get the correct page displayed. So somehow, I need to make a conditional URL rewrite. Thanks, Hans
- Kevin_Stewart
Employee
So you just need to rewrite the URI?
when HTTP_REQUEST { switch -glob [HTTP::header value "User-Agent"] { "*MSIE 6*" - "*MSIE 7*" - "*MSIE 8*" { pool site-10.130.14.98_9610 HTTP::uri "/login" } default { pool site-10.130.14.98_29710 } } }
- htuytela_37346
Nimbostratus
Thank you for your reply. There seems to be a loop in the iRule. It now looks like traffic is being redirected to the virtual server again, with the suffix /login added, which obviously causes this loop when the user uses MSIE. I just would need the /login suffix added, and the pool site-10.130.14.98_9610 to be used. This is my current iRule :
when HTTP_REQUEST { switch -glob [HTTP::header value "User-Agent"] { "*MSIE 6*" - "*MSIE 7*" - "*MSIE 8*" { log local0. "[IP::client_addr]:[TCP::client_port]: Matched MSIE." pool site-10.130.14.98_9610 HTTP::uri "/login" } default { log local0. "[IP::client_addr]:[TCP::client_port]: Matched default pool" pool site-10.130.14.98_29710 } } }
- Thomas_Gobet
Nimbostratus
Can you try this :
when HTTP_REQUEST { switch -glob [HTTP::header value "User-Agent"] { "*MSIE 6*" - "*MSIE 7*" - "*MSIE 8*" { log local0. "[IP::client_addr]:[TCP::client_port]: Matched MSIE." pool site-10.130.14.98_9610 if { ![string tolower [HTTP::uri]] equals "/login" }{ HTTP::uri "/login" } } default { log local0. "[IP::client_addr]:[TCP::client_port]: Matched default pool" pool site-10.130.14.98_29710 } } }
I added a condition for your URI rewriting action.
- htuytela_37346
Nimbostratus
Hi Thomas, unfortunately, that did not work neither. Basically, I'm looking to add the /login suffix for requests made by MSIE users, who then need to be directed to a seperate pool of servers. The actual user is not to type the /login suffix himself. I believe your if statement expects the /login typed in the browser, doesn't it ? So a conditional rewrite of the URL....
- Thomas_Gobet
Nimbostratus
Ok, so you want your user to be redirected to /login page if he uses MSIE 8 ?
Did you try to redirect your user with
HTTP::redirect "http://[HTTP::host]/login"
- htuytela_37346
Nimbostratus
Thanks, this somewhat does the redirect, although I would not like the URL in the browser to change. I'd like to keep it the same for both browsers. how do I do that?
- Thomas_Gobet
Nimbostratus
Or you can do this like that :
when HTTP_REQUEST { switch -glob [HTTP::header value "User-Agent"] { "*MSIE 6*" - "*MSIE 7*" - "*MSIE 8*" { set URI_Origin "[HTTP::uri]" log local0. "[IP::client_addr]:[TCP::client_port]: Matched MSIE." pool site-10.130.14.98_9610 if { ![string tolower [HTTP::uri]] equals "/login" }{ HTTP::uri "/login/$URI_Origin" } } default { log local0. "[IP::client_addr]:[TCP::client_port]: Matched default pool" pool site-10.130.14.98_29710 } } }
You can also take a look at Cookie insertion.
Recent Discussions
Related Content
* 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