Forum Discussion
Mike_Pones_6391
Nimbostratus
Sep 22, 2005User Agent?
I have a customer that is asking if I can make a load balance decition based on the URL and the user agent. I am not familiar with the user agent, but it sounds like it must add something to the request that tells it what browser the client is using.
Has anyone heard of this? I am trying to get more info from the client and possably a sniffer trace.
Thanks in advance.
Mike
5 Replies
- No need for a sniffer trace. The URI is available with the http_uri varaible and the user agent is just a HTTP header that you can query with the http_header command.
if (http_uri starts_with "/dir1/dir2" ) { use pool pool1 } else if (http_uri contains "somthing") { use pool pool2 } else if (http_uri ends_with ".gif") { use pool pool3 }
if (http_header("User-Agent") contains "Opera") { use pool opera_pool } else if (http_header("User-Agent") contains "Firefox") { use pool firefox_pool } else if (http_header("User-Agent") contains "Safari") { use pool safari_pool } else if (http_header("User-Agent") contains "MSIE") { use pool internet_explorer_pool } else if (http_header("User-Agent") contains "Netscape") { use pool netscape_pool } else if (http_header("User-Agent") contains "Mozilla/5.0") { use pool mozilla_pool } else { use pool other_browser_pool }
log local0.debug "Uri: " + http_uri log local0.debug "UserAgent: " + http_header("User-Agent")
- Mike_Pones_6391
Nimbostratus
Joe, you ROCK!!! - Mike_Pones_6391
Nimbostratus
I have been looking in the manual, but where can I get a list of the "header-tag-string" options. - Posted By mpones on 9/22/2005 12:08 PM
- Martin_MachacekHistoric F5 AccountActually Opera allows the user to choose what browser type it reports. It offers Opera, Mozilla 5.0 and MSIE 6.0 :-) In all cases, the User-Agent string contains Opera (either at the begining or at the end). So, you should check for Opera before Mozilla and MSIE because the User-Agent string may contain both of them (along with Opera) ... or use a regular expression to narrow down the match (but it is slower than simple string matches).
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