Forum Discussion
collinz1_17223
Nimbostratus
Jun 06, 2011irule active_members <1 and MSIE 7
I have an irule that returns HTML when all pool members are down, this works fine, hower what i now want to do is return different HTML if users are using IE7. It would be great to be able to return differnt HTML for multiple other browsers (IE6 & IE7) also.
when HTTP_REQUEST {
if { ([active_members [LB::server pool]] < 1) and ( [string tolower [HTTP::header User-Agent]] eq [string tolower "*msie 7.*"])} {
HTTP::respond 200 content {
...
elseif { [active_members [LB::server pool]] < 1} {
HTTP::respond 200 content {
...
8 Replies
- nitass
Employee
when HTTP_REQUEST {
if {[active_members [LB::server pool]] < 1} {
if {[string tolower [HTTP::header User-Agent]] contains "msie 7"} {
do something
} else {
do something else
}
}
} - collinz1_17223
Nimbostratus
Thats great thanks. How would i specify multiple agents in the same line? I have tried the following as an example, but it doesnt appear to work:
when HTTP_REQUEST {
if {[active_members [LB::server pool]] < 1} {
if {[string tolower [HTTP::header User-Agent]] contains "msie 7" or "msie 6"} {
do something
} else {
do something else
}
}
} - nitass
Employee
i think matchclass/class with data group should be good. what bigip version r u running?
matchclass
http://devcentral.f5.com/wiki/default.aspx/iRules/matchclass.html
class
http://devcentral.f5.com/wiki/default.aspx/iRules/class.html - collinz1_17223
Nimbostratus
I'll check that out. Were running v10.2 - collinz1_17223
Nimbostratus
i have setup a data group (called msie) with string values of msie 6 & msie 7 and attempted to reference the group in an irule, but it doesn't appear to be working. Traffic seems to be matching my "else" statement.
when HTTP_REQUEST {
if {[active_members [LB::server pool]] < 1} {
if {[class match [HTTP::header User-Agent] equals "msie" ] } {
do something
} else {
do something else
}
}
} - nitass
Employee
can u try this one?
when HTTP_REQUEST {
if {[active_members [LB::server pool]] < 1} {
if {[class match [HTTP::header User-Agent] contains msie]} {
do something
} else {
do something else
}
}
} - Colin_Walker_12Historic F5 AccountYou'll almost certainly want to use contains, not equals, otherwise you'll have to have the entire and exact entry in the class, and that would be a pain given all the different possible user agent strings. You'll also want to be sure that you're forcing everything to either upper or lowercase for the comparison.
Something like : [class match [string tolower [HTTP::header User-Agent]] contains "msie"]
Colin - collinz1_17223
Nimbostratus
That did indeed work, thanks.
I now have an irule that returns one set of HTML for IE7 and IE6 users when all pool members are down and a different set of HTML for all other users.
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
