如果只允许限定的 UA 访问,需要注意什么?

2014-08-15 20:13:12 +08:00
 pkdbzkrl
https://gist.github.com/anonymous/3c5a626162993915435e
我错过了重要的 UA 了吗?
8188 次点击
所在节点    问与答
10 条回复
Vindia
2014-08-15 20:17:52 +08:00
opera
v1p
2014-08-15 20:22:34 +08:00
搜索引擎不会都在UA里注明身份的,用UA判断会屏蔽许多访问,包括Google和百度
ETiV
2014-08-15 20:24:12 +08:00
我看 cocos2d-html5 代码里还有 qqbrowser, mqqbrowser ...

https://github.com/cocos2d/cocos2d-html5/blob/eaf6b1fcfc7a2f702b0d839c62724f6691447ea9/CCBoot.js#L1291-L1306

```
sys.BROWSER_TYPE_WECHAT = "wechat";
sys.BROWSER_TYPE_ANDROID = "androidbrowser";
sys.BROWSER_TYPE_IE = "ie";
sys.BROWSER_TYPE_QQ = "qqbrowser";
sys.BROWSER_TYPE_MOBILE_QQ = "mqqbrowser";
sys.BROWSER_TYPE_UC = "ucbrowser";
sys.BROWSER_TYPE_360 = "360browser";
sys.BROWSER_TYPE_BAIDU_APP = "baiduboxapp";
sys.BROWSER_TYPE_BAIDU = "baidubrowser";
sys.BROWSER_TYPE_MAXTHON = "maxthon";
sys.BROWSER_TYPE_OPERA = "opera";
sys.BROWSER_TYPE_MIUI = "miuibrowser";
sys.BROWSER_TYPE_FIREFOX = "firefox";
sys.BROWSER_TYPE_SAFARI = "safari";
sys.BROWSER_TYPE_CHROME = "chrome";
sys.BROWSER_TYPE_UNKNOWN = "unknown";
...
var browserTypes = ua.match(/micromessenger|qqbrowser|mqqbrowser|ucbrowser|360browser|baiduboxapp|baidubrowser|maxthon|trident|opera|miuibrowser|firefox/i)
|| ua.match(/chrome|safari/i);
```
omi4399
2014-08-15 20:43:20 +08:00
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2096.0 Safari/537.36 OPR/25.0.1583.1 (Edition Developer)
1up
2014-08-15 20:48:18 +08:00
不想让访问的访客一般都会伪装搜索引擎ua的
pkdbzkrl
2014-08-15 20:53:09 +08:00
@v1p 真的?
sanddudu
2014-08-15 21:41:57 +08:00
Mozilla/5.0 (Mobile; Windows Phone 8.1; Android 4.0; ARM; Trident/7.0; Touch; rv:11.0; IEMobile/11.0; NOKIA; Nokia 925) like iPhone OS 7_0_3 Mac OS X AppleWebKit/537 (KHTML, like Gecko) Mobile Safari/537
guoer
2014-08-15 23:58:47 +08:00
形同虚设吧 都可以伪装的
v1p
2014-08-16 04:59:15 +08:00
@pkdbzkrl 给你随手找了三条,你看看它们是谁 :)

61.135.186.56 - - [2014-08-11 01:25:31] "GET / HTTP/1.1" 200 7311 "-" "Mozilla/5.0 (iphone; U; CPU iPhone OS 4_3_5 like Mac OS X; zh-cn) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8J2 Safari/6533.18.5" "-"
220.181.51.74 - - [2014-08-11 08:10:14] "GET / HTTP/1.1" 200 11460 "-" "Mozilla/5.0 (Windows NT 5.1; rv:6.0.2) Gecko/20100101 Firefox/6.0.2"
66.249.84.84 - - [2014-07-04 16:41:58] "GET / HTTP/1.1" 200 11439 "-" "Mozilla/5.0 (Windows NT 6.1; rv:6.0) Gecko/20110814 Firefox/6.0"
lm902
2014-08-16 07:50:56 +08:00
Mozilla/5.0 (MSIE 9.0; qdesk 2.4.1265.203; Windows NT 6.3; WOW64; Trident/7.0; .NET4.0E; .NET4.0C; Tablet PC 2.0; .NET CLR 3.5.30729; .NET CLR 2.0.50727; .NET CLR 3.0.30729; LCJB; QQBrowser/7.7.26127.400; rv:11.0) like Gecko

IE11被腾讯某软件篡改成IE9的UA表示鸭梨略大

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/128140

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX