In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
This article describes the configuration in which Nginx forbids specified UA access.
UA, or Http User Agent, uses the built-in variable $http_user_agent in Nginx to indicate that this information is sent to webserver as part of request header. Therefore, for webserver, one way to prohibit access is to judge the UA.
Prohibit search engine crawlers
Because, you know, I don't really want crawlers like Baidu to come to my website, so I use if to judge UA in Nginx:
If ($http_user_agent ~ * "qihoobot | Baidu | Baiduspider | Baiduspider-image | Baiduspider-video | Baiduspider-news | Baiduspider-favo | Baiduspider-cpro | Baiduspider-ads | Baiduboxapp | YisouSpider | EasouSpider | YodaoBot | YoudaoBot | Sosospider | Sogou | ^ $") {return 444;}
Prohibit downloading tools
If ($http_user_agent ~ * "Scrapy | HttpClient | Curl | Wget | Idm | Aria2 | Axel | Thunder | Youtube-dl | Movgrab | rtorrent | ctorrent | Transmission-cli | vuze") {return 444;}
Access to domestic browsers is prohibited
If ($http_user_agent ~ * | 360SE | 360EE | 2345Explorer | maxthon | sogou | qiyu | green | qq | qqbrowser | tt | liebao | lbbrowser | tao | taobao | coolnovo | saayaa | mi | xiaomi | baidu | yandex | wechat | weibo | douban | suning | iqiyi | alipay | ali-ap | ali-ap-pd | ali-am | ali-tb | ali-tb-pd | ali-tb-pd | ali-tb-pd ") {ali-tm 444;}
Disable access to the specified system
There are also some domestic systems, such as aliyun os, which I also want to ban:
If ($http_user_agent ~ * "yunos") {return 444;}
Conclusion
As you can see from the above, to judge UA, the rule is:
If ($http_user_agent ~ * "UA keyword") {.}
However, the disadvantage of this method is obvious, because UA is too easy to forge, but it is OK to guard against requests without forgery (such as domestic search crawlers). Of course, there are some more reliable ways, such as the verification of session.
The above is the whole content of this article, I hope it will be helpful to your study, and I also hope that you will support it.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.