首页 > 数据库技术 > 详细

nginx过滤access_log中HEAD、OPTIONS请求记录

时间:2019-11-16 15:08:35      阅读:112      评论:0      收藏:0      [点我收藏+]

网上很多教程说是这样做:

if ($request_method = HEAD) {
    access_log off;
}

试了之后是不行的,正确的做法如下:

技术分享图片
http {
    map $request_method $loggable {
        HEAD 0;
        OPTIONS 0;
        default 1;
    }

    log_format main ‘$remote_addr [$time_local] $request $status $body_bytes_sent $http_user_agent‘;
    access_log /var/log/nginx/access.log main if=$loggable;
}
技术分享图片

这里过滤掉了HEAD和OPTIONS请求

官方文档地址:http://nginx.org/en/docs/http/ngx_http_log_module.html

技术分享图片

 

nginx过滤access_log中HEAD、OPTIONS请求记录

原文:https://www.cnblogs.com/lixiuran/p/11871751.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!