服务器之家:专注于服务器技术及软件下载分享
分类导航

云服务器|WEB服务器|FTP服务器|邮件服务器|虚拟主机|服务器安全|DNS服务器|服务器知识|Nginx|IIS|Tomcat|

服务器之家 - 服务器技术 - Nginx - nginx服务器access日志中大量400 bad request错误的解决方法

nginx服务器access日志中大量400 bad request错误的解决方法

2019-10-25 14:15junjie Nginx

这篇文章主要介绍了nginx服务器access日志中大量400 bad request错误的解决方法,本文结论是空主机头导致的大量400错误日志,关闭默认主机的日志记录就可以解决问题,需要的朋友可以参考下

在access.log中有大量400错误,并以每天几百M的速度增加,占用大量空间.

复制代码代码如下:


tail -f /opt/nginx/logs/access.log

 

    116.236.228.180 - - [15/Dec/2010:11:00:15 +0800] "-" 400 0 "-" "-"
    116.236.228.180 - - [15/Dec/2010:11:00:15 +0800] "-" 400 0 "-" "-"
    116.236.228.180 - - [15/Dec/2010:11:00:15 +0800] "-" 400 0 "-" "-"
    116.236.228.180 - - [15/Dec/2010:11:00:15 +0800] "-" 400 0 "-" "-"
    116.236.228.180 - - [15/Dec/2010:11:00:15 +0800] "-" 400 0 "-" "-"
    119.97.196.7 - - [15/Dec/2010:11:00:16 +0800] "-" 400 0 "-" "-"
    119.97.196.7 - - [15/Dec/2010:11:00:16 +0800] "-" 400 0 "-" "-"
    116.236.228.180 - - [15/Dec/2010:11:00:16 +0800] "-" 400 0 "-" "-"
    116.236.228.180 - - [15/Dec/2010:11:00:16 +0800] "-" 400 0 "-" "-"
    116.236.228.180 - - [15/Dec/2010:11:00:16 +0800] "-" 400 0 "-" "-"
    116.236.228.180 - - [15/Dec/2010:11:00:16 +0800] "-" 400 0 "-" "-"
    116.236.228.180 - - [15/Dec/2010:11:00:16 +0800] "-" 400 0 "-" "-"
    116.236.228.180 - - [15/Dec/2010:11:00:16 +0800] "-" 400 0 "-" "-"
    116.236.228.180 - - [15/Dec/2010:11:00:16 +0800] "-" 400 0 "-" "-"
    116.236.228.180 - - [15/Dec/2010:11:00:16 +0800] "-" 400 0 "-" "-"
    219.243.95.197 - - [15/Dec/2010:11:00:16 +0800] "-" 400 0 "-" "-"
    116.236.228.180 - - [15/Dec/2010:11:00:16 +0800] "-" 400 0 "-" "-"
    116.236.228.180 - - [15/Dec/2010:11:00:16 +0800] "-" 400 0 "-" "-"


网上大把的文章说是HTTP头/Cookie过大引起的,可以修改nginx.conf中两参数来修正.

复制代码代码如下:

    client_header_buffer_size 16k;
          large_client_header_buffers 4 32k;


修改后

复制代码代码如下:

    client_header_buffer_size 64k;
         large_client_header_buffers 4 64k;


没有效果,就算我把nginx0.7.62升到最新的0.8.54也没能解决.
在官方论坛中nginx作者提到空主机头不会返回自定义的状态码,是返回400错误.
http://forum.nginx.org/read.php?2,9695,11560

 

最后修正如下
改为原先的值

复制代码代码如下:

    client_header_buffer_size 16k;
         large_client_header_buffers 4 32k;


关闭默认主机的日志记录就可以解决问题

复制代码代码如下:

    server {
    listen *:80 default;
    server_name _;
    return 444;
    access_log   off;
    }

延伸 · 阅读

精彩推荐