HTTP2.0 拦截爬虫的tips

作者: print("") 分类: 信息安全 发布时间: 2021-05-22 09:51

首要条件

Nginx1.10.0以上版本才支持Http2.0,如果使用的是Tengine,版本需要大于2.2.1
Http2.0只支持Https协议的网站,且openssl版本需要高于1.0.2

一、查看当前Nginx安装了哪些模块(如果事先没有安装Nginx,请忽略此步

nginx -V

检查是否安装了模块–with-http_v2_module

三、配置Nginx
Nginx配置http2很简单,只需要在listen的端口后新增http2标识即可,如下

    listen       443 ssl http2;

然后访问一下

设置禁止访问HTTP1.1

  if ($server_protocol !~* "HTTP/2") {
  return 444;
}

Burp 现在只能1.1 测试如下

试试requests 的爬虫

然后现在有些爬虫只能1.1  配置如下的设置即可

  set $flag 0;
  if ($server_protocol !~* "HTTP/2"){ 
  	set $flag "1";
  }
  if ($request_method !~ ^(GET|HEAD|POST)$) {
  	set $flag "1";
  }
  if ($http_user_agent ~* (baiduspider|googlebot|soso|bing|sogou|yahoo|sohu-search|yodao|YoudaoBot|robozilla|msnbot|MJ12bot|NHN|Twiceler)){ 
  	set $flag "0";
  }

  if ($flag = "1"){
  	return 404;
  }

如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!

发表评论

您的电子邮箱地址不会被公开。