Skip to content

Instantly share code, notes, and snippets.

@calind
Created October 12, 2011 17:44
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save calind/1281950 to your computer and use it in GitHub Desktop.
nginx user agent type detection (requires nginx >= 1.0.4)
# agent type detection, based on idea from from http://notnotmobile.appspot.com/
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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment