Forum Discussion
James_124570
Mar 20, 2015Nimbostratus
Trying to change HTTP header User agent
Hi everyone!
I am trying to log the http:header user-agent to a variable using an iRule. I am trying to log exactly what broswer the client is using:(IE, FF, Chrome). Right now, the log shows: "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)" Here is what I have so far.
when HTTP_REQUEST {
if {[HTTP::header "User-Agent"] contains "Firefox"} then {
set user_agent "Firefox" }
elseif {[HTTP::header "User-Agent"] contains "Chrome"} then {
set user_agent "Chrome" }
else {
set user_agent "IE"
log local0. "User Agent is: $user_agent"
}
}
but the logs shows the same output.
Any help would be great!
Thanks everyone!
- James_124570Nimbostratus
Found the issue! Thanks!
- ssievers_87378Nimbostratus
when HTTP_REQUEST { if {[HTTP::header "User-Agent"] contains "Firefox"} then { set user_agent "Firefox" } elseif {[HTTP::header "User-Agent"] contains "Chrome"} then { set user_agent "Chrome" } else { set user_agent "IE" } log local0. "User Agent is: $user_agent" }
- James_124570Nimbostratus
even took a step further:
if {[HTTP::header "User-Agent"] contains "Firefox"} then { set User_agent "Firefox" } elseif {[HTTP::header "User-Agent"] contains "Chrome"} then { set User_agent "Chrome" } elseif {[HTTP::header "User-Agent"] contains "Trident/5.0"} then { set User_agent "Internet Explorer-v9.0" } elseif {[HTTP::header "User-Agent"] contains "Trident/6.0"} then { set User_agent "Internet Explorer-v10.0" } elseif {[HTTP::header "User-Agent"] contains "Trident/7.0"} then { set User_agent "Internet Explorer-v11.0" } else { set User_agent "Safari" log local0. "Http_version is = $http_version" }
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