nginx 每天都有很多400的錯誤,如何解決?
# cat access-20091227.log | awk -F' ' '$9 == "400" || $9 == "408" || $9 == "499" || $9 == "500" || $9 =="502" || $9 =="504" {print $9}' | sort | uniq -c | more
7541 400
4711 408
562 499
4 500
1 502
基本上每天都有這麼多,動態和靜態頁面都會出現400錯誤。版本是nginx/0.7.64
client_header_buffer_size 128k;
large_client_header_buffers 4 256k;
上面兩個參數改了沒有效果。不知400還有可能是哪方面原因?
《解決方案》
是不是fastcgi問題,你應該把nginx.conf都列出來
《解決方案》
fastcgi有問題,靜態頁面就不會也出現了,靜態頁面不走fastcgi。
《解決方案》
nginx.conf文件,192.168.1.2是squid proxy,跑靜態頁,192.168.1.4和192.168.1.5是nginx+fastcgi,主要是跑動態頁:
user httpd httpd;
worker_processes 8;
error_log /web/logs/error.log notice;
pid /var/run/nginx.pid;
worker_rlimit_nofile 51200;
events {
# use [ kqueue | rtsig | epoll | /dev/poll | select | poll ] ;
use epoll;
#maxclient = worker_processes * worker_connections / cpu_number
worker_connections 51200;
}
http {
include mime.types;
default_type application/octet-stream;
access_log off;
server_names_hash_bucket_size 128;
client_header_buffer_size 128k;
large_client_header_buffers 4 256k;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 300;
proxy_temp_path /dev/shm/proxy_temp;
fastcgi_temp_path /dev/shm/fastcgi_temp;
client_body_temp_path /dev/shm/client_body_temp;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 10m;
client_body_buffer_size 256k;
proxy_connect_timeout 300;
proxy_send_timeout 300;
proxy_read_timeout 300;
proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;
proxy_temp_file_write_size 64m;
proxy_ignore_client_abort on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
fastcgi_intercept_errors on;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;
output_buffers 1 32k;
postpone_output 1460;
upstream phpstream {
server 192.168.1.4:9000 weight=1 max_fails=3 fail_timeout=3s;
server 192.168.1.5:9000 weight=1 max_fails=3 fail_timeout=3s;
}
upstream htmlstream {
# 192.168.1.2 is squid proxy
server 192.168.1.2:8080;
server 192.168.1.5 backup;
server 192.168.1.4 backup;
}
upstream bbsstream {
server 192.168.1.104;
}
server {
listen 80 default backlog=8192;
server_name xxxx.com;
access_log /web/logs/access.log combined;
error_log /web/logs/error.log error;
root /home/httpd/xxxx.com/web ;
index index.php index.html index.htm;
location ~ ^/forum.*$
{
proxy_pass http://bbsstream;
access_log off;
}
location ~ .*/$
{
fastcgi_pass phpstream;
fastcgi_index index.php;
include fastcgi_params;
}
location ~ .*\.(php|php5)?$
{
if ( $request_uri ~* \/(gateway|gateway2|ajax|feedCount)\.php ) {
access_log off;
}
fastcgi_pass phpstream;
fastcgi_index index.php;
include fastcgi_params;
}
location ~ .*\.(htm|html)?$
{
proxy_pass http://htmlstream;
}
location ~ .*$
{
proxy_pass http://htmlstream;
access_log off;
}
}
}
《解決方案》
不是fastcgi問題