nginx的访问日志access.log中400错误的请求
在nginx的access.log中存在大量的400錯誤,並以每天幾百M的速度增加,佔用大量空間。
事例
106.236.228.100 - - [11/Apr/2014:11:00:15 +0800] "-" 400 0 "-" "-"
106.236.228.100 - - [11/Apr/2014:11:00:15 +0800] "-" 400 0 "-" "-"
106.236.228.100 - - [11/Apr/2014:11:00:15 +0800] "-" 400 0 "-" "-"
106.236.228.100 - - [11/Apr/2014:11:00:15 +0800] "-" 400 0 "-" "-"
106.236.228.100 - - [11/Apr/2014:11:00:15 +0800] "-" 400 0 "-" "-"
119.917.196.7 - - [11/Apr/2014:11:00:16 +0800] "-" 400 0 "-" "-"
119.917.196.7 - - [11/Apr/2014:11:00:16 +0800] "-" 400 0 "-" "-"
116.236.228.180 - - [11/Apr/2014:11:00:16 +0800] "-" 400 0 "-" "-"
解決方法如果你主機綁定根目錄直接修改nginx.confg即可若是你有新建虛擬機許修改相應的域名配置文件
打開配置文件原始内容為
server
{
listen 80;
server_name xxx.com;
index index.html index.htm index.php default.html default.htm default.php;
root /home/wwwroot/xxx;
現在只需添加一個詞default即可添加在listen 80; 的80後邊即listen 80 default;
修正完成后的内容為
server
{
listen 80 default;
server_name xxx.im;
index index.html index.htm index.php default.html default.htm default.php;
root /home/wwwroot/xxx;
也可以直接關閉日誌
access_log off
重啓nginx
/etc/init.d/nginx restart