我是靠谱客的博主 健忘翅膀,这篇文章主要介绍nginx反爬虫配置,现在分享给大家,希望可以做个参考。

#forbidden Scrapy
if ($http_user_agent ~* (Scrapy|Curl|HttpClient))
{
    return 403;
}

#forbidden UA
if ($http_user_agent ~ "Bytespider|FeedDemon|JikeSpider|Indy Library|Alexa Toolbar|AskTbFXTV|AhrefsBot|CrawlDaddy|CoolpadWebkit|Java|Feedly|UniversalFeedParser|ApacheBench|Microsoft URL Control|Swiftbot|ZmEu|oBot|jaunty|Python-urllib|lightDeckReports Bot|YYSpider|DigExt|YisouSpider|HttpClient|MJ12bot|heritrix|EasouSpider|Ezooms|^$" )
{
    return 403;
}

#forbidden not GET|HEAD|POST method access
if ($request_method !~ ^(GET|HEAD|POST)$)
{
    return 403;
}

nginx中location模块的详细参数介绍
Nginx的Location可以有以下几个匹配:

  1. = 严格匹配这个查询。如果找到,停止搜索。
  2. ^~ 匹配路径的前缀,如果找到,停止搜索。
  3. ~ 为区分大小写的正则匹配
  4. ~* 为不区分大小写匹配
    5.!和!*分别为区分大小写不匹配及不区分大小写不匹配

https://www.cnblogs.com/itsharehome/p/11114588.html

最后

以上就是健忘翅膀最近收集整理的关于nginx反爬虫配置的全部内容,更多相关nginx反爬虫配置内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(61)

评论列表共有 0 条评论

立即
投稿
返回
顶部