Skip to content

Instantly share code, notes, and snippets.

@tonmanna
Created August 19, 2018 07:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tonmanna/2e5b3be764b3a28b8e7a47a705a3be53 to your computer and use it in GitHub Desktop.
Save tonmanna/2e5b3be764b3a28b8e7a47a705a3be53 to your computer and use it in GitHub Desktop.
Nginx mapping for detecting device type from the user agent string
map $http_user_agent $device_type
{
default "desktop";
# Mobile bots
"~*SAMSUNG-SGH-E250\/1\.0 Profile\/MIDP-2\.0 Configuration\/CLDC-1\.1 UP\.Browser\/6\.2\.3\.3\.c\.1\.101 \(GUI\) MMP\/2\.0 \(compatible; Googlebot-Mobile\/2\.1; \+http:\/\/www\.google\.com\/bot\.html\)" 'botm';
"~*DoCoMo\/2\.0 N905i\(c100;TB;W24H16\) \(compatible; Googlebot-Mobile\/2\.1; \+http:\/\/www\.google\.com\/bot\.html\)" "botm";
"~*Mozilla\/5\.0 \(iPhone; CPU iPhone OS 8_3 like Mac OS X\) AppleWebKit\/600\.1\.4 \(KHTML, like Gecko\) Version\/8\.0 Mobile\/12F70 Safari\/600\.1\.4 \(compatible; Googlebot\/2\.1; \+http:\/\/www\.google\.com\/bot\.html\)" "botm";
"~*Mozilla\/5\.0 \(Linux; Android 6.0.1; Nexus 5X Build/MMB29P\) AppleWebKit\/537\.36 \(KHTML, like Gecko\) .+ \(compatible; Googlebot\/2.1; \+http:\/\/www\.google\.com\/bot\.html\)" "botm";
# Bots
"~*(ads|google|bing|msn|yandex|baidu|ro|career|)bot" "bot";
"~*(baidu|jike|symantec)spider" "bot";
"~*scanner" "bot";
"~*(web)crawler" "bot";
# Desktop
"~*ipad" "desktop";
"~*(android 3|Nexus (7|10))" "desktop";
"~*(SAMSUNG.*Tablet|Galaxy.*Tab|SC-01C|GT-P1000|GT-P1003|GT-P1010|GT-P3105|GT-P6210|GT-P6800|GT-P6810|GT-P7100|GT-P7300|GT-P7310|GT-P7500|GT-P7510|SCH-I800|SCH-I815|SCH-I905|SGH-I957|SGH-I987|SGH-T849|SGH-T859|SGH-T869|SPH-P100|GT-P3100|GT-P3108|GT-P3110|GT-P5100|GT-P5110|GT-P6200|GT-P7320|GT-P7511|GT-N8000|GT-P8510|SGH-I497|SPH-P500|SGH-T779|SCH-I705|SCH-I915|GT-N8013|GT-P3113|GT-P5113|GT-P8110|GT-N8010|GT-N8005|GT-N8020|GT-P1013|GT-P6201|GT-P7501|GT-N5100|GT-N5105|GT-N5110|SHV-E140K|SHV-E140L|SHV-E140S|SHV-E150S|SHV-E230K|SHV-E230L|SHV-E230S|SHW-M180K|SHW-M180L|SHW-M180S|SHW-M180W|SHW-M300W|SHW-M305W|SHW-M380K|SHW-M380S|SHW-M380W|SHW-M430W|SHW-M480K|SHW-M480S|SHW-M480W|SHW-M485W|SHW-M486W|SHW-M500W|GT-I9228|SCH-P739|SCH-I925|GT-I9200|GT-I9205|GT-P5200|GT-P5210|GT-P5210X|SM-T311|SM-T310|SM-T310X|SM-T210|SM-T210R|SM-T211|SM-P600|SM-P601|SM-P605|SM-P900|SM-P901|SM-T217|SM-T217A|SM-T217S|SM-P6000|SM-T3100|SGH-I467|XE500|SM-T110|GT-P5220|GT-I9200X|GT-N5110X|GT-N5120|SM-P905|SM-T111|SM-T2105|SM-T315|SM-T320|SM-T320X|SM-T321|SM-T520|SM-T525|SM-T530NU|SM-T230NU|SM-T330NU|SM-T900|XE500T1C|SM-P605V|SM-P905V|SM-P600X|SM-P900X|SM-T210X|SM-T230|SM-T230X|SM-T325|GT-P7503|SM-T531|SM-T330|SM-T530|SM-T705C|SM-T535|SM-T331|SM-T800|SM-T700)" "desktop";
# Mobile
"~*ip(hone|od)" "mobile";
"~*android.*(mobile|mini)" "mobile";
"~*Opera Mobi" "mobile";
"~*PlayBook; U; RIM Tablet" "mobile";
"~*hp-tablet.*TouchPad" "mobile";
"~*Kindle/3" "mobile";
"~*Mobile.+Firefox" "mobile";
"~*^HTC" "mobile";
"~*Fennec" "mobile";
"~*IEMobile" "mobile";
"~*BlackBerry" "mobile";
"~*BB10.*Mobile" "mobile";
"~*GT-.*Build/GINGERBREAD" "mobile";
"~*SymbianOS.*AppleWebKit" "mobile";
"~*symbian" "mobile";
"~*sonyericsson" "mobile";
"~*nokia" "mobile";
"~*samsung" "mobile";
"~*lg" "mobile";
"~*bada" "mobile";
"~*blazer" "mobile";
"~*palm" "mobile";
"~*nintendo wii" "mobile";
"~*playstation portable" "mobile";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment