Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
nginx user agent type detection (requires nginx >= 1.0.4)
# agent type detection, based on idea from from
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