我用php-cgi使用nginx。 最近出现了一个问题,如果你不查看我的网站一段时间,比如3-4分钟,然后再打开它,你发送的第一个请求将返回在浏览器中被同位体重置的连接。 如果刷新,所有后续请求的操作都是正常的。 这种情况每次都会发生,这不仅仅是一个孤立的事件,它发生在每个人使用我的网站。 我试图重新启动nginx和php-cgi,但无济于事。 有谁知道是什么问题? 我可以提供任何必要的信息。
值得注意的是,除了有关客户端提前closures连接的消息之外,没有任何错误日志。
nginx.conf
user nobody; worker_processes 4; error_log /var/log/nginx/error.log; pid /var/run/nginx.pid; events { worker_connections 2048; } http { include /etc/nginx/mime.types; error_page 404 /404.html; error_page 403 /403.html; error_page 444 /444.html; error_page 502 /502.html; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; large_client_header_buffers 8 8k; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 30; server_tokens off; gzip on; gzip_proxied any; gzip_comp_level 6; gzip_buffers 64 8k; gzip_min_length 1024; gzip_http_version 1.1; gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript; include /etc/nginx/conf.d/*.conf; }
default.conf
server { listen 80; server_name domain.com; error_log /var/log/nginx/error.log debug; access_log /var/log/nginx/access.log; location / { if ($request_method !~ ^(GET|HEAD|POST)$ ) { return 444; } if ($http_user_agent ~* Havij|hvj|acunetix|wget|HTtrack) { return 403; } root /home/admin06/public_html; autoindex off; index index.php; # Images and static content is treated different location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ { access_log off; expires 30d; root /home/admin06/public_html; } location /nginx_status { stub_status on; access_log off;] deny all; } location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.*)$; #try_files $uri =404; fastcgi_pass backend; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /home/site/public_html$fastcgi_script_name; include fastcgi_params; fastcgi_param QUERY_STRING $query_string; fastcgi_param REQUEST_METHOD $request_method; fastcgi_param CONTENT_TYPE $content_type; fastcgi_param CONTENT_LENGTH $content_length; fastcgi_intercept_errors on; fastcgi_ignore_client_abort off; fastcgi_connect_timeout 60; fastcgi_send_timeout 60; fastcgi_read_timeout 60; fastcgi_buffer_size 128k; fastcgi_buffers 4 256k; fastcgi_busy_buffers_size 256k; fastcgi_temp_file_write_size 256k; } ## Disable viewing .htaccess & .htpassword location ~ /\.ht { deny all; } location ~ error_log { deny all; } location ~ access_log { deny all; } location ~ \.cgi { deny all; } location ~ \.db { deny all; } }
您应该首先确定在PHP(php.ini,php-cgi)级别或在您的应用程序级别发生此错误的层(即在服务器级别(Linux机器configuration))。 HTTP错误可能是由于这些层中的错误configuration导致的,因此您需要先隔离并确定服务器发生故障的位置(双关意图)。
我的build议是跟踪HTTP请求:
通过这种方式,在服务器故障中的好人能够帮助您正确解决问题之前,您将能够确切地确定问题所在。
还张贴您的nginx.conf,default.conf,php-fpm.conf有关您的应用程序的一些细节也将很好。
一个新的nginx更新(1.2.5),并更新到新版本修复了这个问题。