限定user_agent
限定user_agent当服务器被***,并且查看到***的user_agent有规律,这时就需要限制user_agent
user_agent配置如下
# vim /usr/local/apache2.4/conf/extra/httpd-vhosts.conf
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT}.*curl.*
RewriteCond %{HTTP_USER_AGENT}.*baidu.com.*
RewriteRule.*-
(增加如上配置,配置详解如下:(这里需要用到rewrite模块)
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT}.*curl.* (OR是或者的意思,或者匹配curl,或者匹配baidu.com)(NC忽略大小写)
RewriteCond %{HTTP_USER_AGENT}.*baidu.com.*
RewriteRule.*-(F的含义‘forbiddenF’ (force URL to be forbidden)重写为禁止访问
测试user_agent
# curl -A "chylinux chylinux" -x192.168.212.10:80 'http://www.111.com/123.php' -I
HTTP/1.1 200 OK
Date: Thu, 03 Aug 2017 22:43:50 GMT
Server: Apache/2.4.27 (Unix) PHP/5.6.30
X-Powered-By: PHP/5.6.30
Content-Type: text/html; charset=UTF-8
(curl -A 指定user_agent)
# curl-x192.168.212.10:80 'http://www.111.com/123.php' -I
HTTP/1.1 403 Forbidden
Date: Thu, 03 Aug 2017 22:53:09 GMT
Server: Apache/2.4.27 (Unix) PHP/5.6.30
Content-Type: text/html; charset=iso-8859-1
(这个如果不指定user_agent的结果)
curl -e "http//" (指定)
页:
[1]