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

Sara/Sarah ·
更新时间:2024-11-14
· 596 次阅读

在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;
    }

您可能感兴趣的文章:Nginx 499错误问题及解决办法HTTP 499 状态码 nginx下 499错误的解决办法Nginx+CI框架出现404错误怎么解决修改配置解决Nginx服务器中常见的上传与连接错误Nginx服务器中配置404错误页面时一些值得注意的地方Nginx服务器中414错误和504错误的配置解决方法Nginx 502 Bad Gateway错误常见的4种原因和解决方法Nginx反向代理proxy_cache_path directive is not allowed错误解决方法Linux服务器nginx访问日志里出现大量http 400错误的请求分析Nginx PHP-Fcgi中因PHP执行时间导致504 Gateway Timeout错误解决记录权限问题导致Nginx 403 Forbidden错误的解决方法Nginx启动常见错误及解决方法



400 bad request 中大 bad 方法 request access Nginx

需要 登录 后方可回复, 如果你还没有账号请 注册新账号