zoukankan      html  css  js  c++  java
  • 解决nginx access日志中400 bad request 错误(转)

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

  • 相关阅读:
    【eoe资源】通过片段创建灵活的用户界面
    史上最全的Android开发索引帖
    临时记录
    五种开源协议的比较(BSD,Apache,GPL,LGPL,MIT)
    【转】深入探讨 Android 传感器
    Java Collections Framework Java集合框架List,Map,Set等全面介绍之概要篇
    谷歌 G1 android APK安装器 离线安装软件
    【转】請為你的 Android 程式加上 obfuscation 吧!
    【转】Android Toolchain与Bionic Libc
    用VirtualBox在XP环境下虚拟Ubuntu的过程
  • 原文地址:https://www.cnblogs.com/xiangxiaodong/p/3553829.html
Copyright © 2011-2022 走看看