Nginx user agent type detection

I have assembled a way to detect user agent types by using ideas from:
http://notnotmobile.appspot.com/

This is the inital work I came up with:

map $http_user_agent $agent_type_phase1 {
default ‘mobile’;
‘’ ‘unknown’;
~*iphone|ipod|blackberry|palm|windows\s+ce ‘mobile’;
~*windows|linux|os\s+[x9]|solaris|bsd ‘desktop’;
~*spider|crawl|slurp|bot|feedburner ‘bot’;
}
map $http_x_skyfire_phone $agent_type_phase2 {
default ‘mobile’;
‘’ $agent_type_phase1;
}
map $http_x_operamini_phone_ua $agent_type {
default ‘mobile’;
‘’ $agent_type_phase2;
}

Please suggest any improvements. It is available also on

I did it in lua bcs I had slightly more complex rules. Looks like what
you
have will work, it’s just O(n)

On 12 October 2011 22:17, Brian A. [email protected] wrote:

I did it in lua …
Care to share?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs