apache httpd 不记录head 的请求。

比如说用了阿里云的slb ,然后他会检测服务器是否正常运行,通常会发大量的HEAD 请求过来。

这样有规则的请求是可以屏蔽的。步骤如下:

  1. 在 <Directory />中添加 SetEnvIf Request_Method HEAD dontlog
  2. CustomLog 中修改成 CustomLog logs/access_log combined env=!dontlog
  3. reload 即可。

可参考http://www.howtoforge.com/setenvif_apache2

官网http://httpd.apache.org/docs/2.2/mod/mod_setenvif.html

不只是Request_Method 还有其他变量也可以进行判断

  • Host
  • User-Agent
  • Referer
  • Accept-Language
  • Remote_Host: the hostname (if available) of the client making the request.
  • Remote_Addr: the IP address of the client making the request.
  • Server_Addr: the IP address of the server on which the request was received (only with versions later than 2.0.43).
  • Request_Method: the name of the method being used (GET, POST, etc.).
  • Request_Protocol: the name and version of the protocol with which the request was made (e.g., "HTTP/0.9", "HTTP/1.1", etc.).
  • Request_URI: the resource requested on the HTTP request line - generally the portion of the URL following the scheme and host portion without the query string.

nginx 里面就简单一些

if ( $request_method = "HEAD" )

{

  access_log off ;

}

posted @ 2014-07-21 13:40  过去的我  阅读(1146)  评论(0编辑  收藏  举报