Forum Discussion
john_mcgarrigle
Nimbostratus
Jan 10, 2008Detect browser JRE version?
I am completely new to F5 and iRules, so please excuse my lack of knowledge about what iRules are able to do. I am working on a project where the project manager would like for me to move traffic to different locations depending on a user's browser type and the Java plug-in it is using. I know that detecting the browser user_agent is fairly easy to do with iRules, but I have not found anything that indicates that the version of the Java plug-in can be determined.
Does anyone know if it is possible to determine Java plug-in version this with iRules? If it is possible, could you please point me to a resource that would show me how to do this? Thank you in advance for your help and patience with me.
6 Replies
- hoolio
Cirrostratus
I think the only time you'd see the JRE version number in any HTTP request headers is if the JVM actually makes the request. Browser user-agent strings don't normally include the JRE version number. If you look at your web server logs or other people's logs on the web, you don't typically see the JRE number.
Here's a handy UA reference site:
http://www.useragentstring.com/pages/useragentstring.php (Click here)
Aaron - hoolio
Cirrostratus
Actually, it looks like the client JRE downloads JAR files and includes the JRE version number in the User-Agent string:
GET /hyperstat/normal_p_shade.jar HTTP/1.1
content-type: application/x-java-archive
accept-encoding: pack200-gzip,gzip
Host: davidmlane.com
Cache-Control: no-cache
Pragma: no-cache
User-Agent: Mozilla/4.0 (Windows XP 5.1) Java/1.6.0_03
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Proxy-Connection: keep-alive
If-Modified-Since: Thu, 07 Sep 2006 17:23:00 GMT
Here is an example which checks each HTTP request. If the request contains "java/", it parses the first three digits in the version string and sets a pool based on the first two:when HTTP_REQUEST { Log debug messages to /var/log/ltm? 1=yes, 0=no set java_version_debug 1 Check if the User-Agent header contains the string "java/" if {[string tolower [HTTP::header value User-Agent]] contains "java"}{ Parse out the Java version from "some text java/1.6.0 some text" to "1.6.0" switch -glob [string range [getfield [string tolower [HTTP::header value User-Agent]] "java/" 2] 0 4] { 1.6.* { Log a debug message to /var/log/ltm if {$java_version_debug}{log local0. "Matched 1.6.*"} Set the pool to the v1.6 pool pool java_1.6.x_pool } 1.5.* { if {$java_version_debug}{log local0. "Matched 1.5.*"} pool java_1.5.x_pool } 1.4.* { if {$java_version_debug}{log local0. "Matched 1.4.*"} pool java_1.4.x_pool } default { if {$java_version_debug}{log local0. "Matched default"} pool java_default_pool } } } }
This assumes that you don't need to send client requests to the same pool they may have requested without the Java string in the User-Agent header.
Here is a version with intermediate variables that might help if you want to follow the commands:when RULE_INIT { set user_agent "Mozilla/4.0 (Windows XP 5.1) Java/1.6.0_03 test" set user_agent [string tolower $user_agent] log local0. "\$user_agent: $user_agent" set java_version_string [getfield $user_agent "java/" 2] log local0. "\$java_version_string: $java_version_string" set java_version [string range $java_version_string 0 4] log local0. "\$java_version: $java_version" log local0. "Test: [string range [getfield [string tolower $user_agent] "java/" 2] 0 4]" }
Sample log output:
Rule : mozilla/4.0 (windows xp 5.1) java/1.6.0_03 test
Rule : $java_version_string: 1.6.0_03 test
Rule : $java_version: 1.6.0
Rule : Test: 1.6.0
Holler if you have questions...
Aaron - john_mcgarrigle
Nimbostratus
Aaron -
Holy moly, thank you for the reference site, the explanation, and the iRule to boot. I did not expect someone to do my work for me - THANK YOU! I should have access to our new devices in the next week, I'll report back on my results.
Thanks again -
j - JRahm
Admin
Aaron is a genuine superhero around here. Aaron's contribution to this site is what community is all about! - Colin_Walker_12Historic F5 AccountYou've got that right! Thanks again for all the efforts Aaron, without users like you and citizen_elah, DevCentral wouldn't be anything near what it is today.
Thanks so much to you and all the other users that contribute! Keep it up!
Colin - hoolio
Cirrostratus
They're all fun little puzzles to figure out. And thanks to everyone else that posts for us to learn from.
Aaron
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
