Upstream closed connection...

Gen Gennix lists at ruby-forum.com
Wed Sep 17 20:09:31 MSD 2008


Hi,

I'm using Nginx+PHP+MySQL on CentOS since two weeks and it works great
(with 20 000 visitors/day).

But every minutes, I received several errors like this one :

2008/09/16 12:39:30 [error] 25031#0: *5786740 upstream prematurely
closed connection while reading response header from upstream, client:
99.99.9.199, server: localhost, request: "GET /search?query=test&pag
e_number=8 HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host:
"www.****.com", referrer:
"http://www.****.com/search?query=test&page_number=7"

My only clues are:

1- "fastcgi_read_timeout 180;" doesn't solve my problem.

2- The error occured before executing the first line of my php script.
So, it's not a MySQL problem, nor a php script problem.

3- There was a lot of "TIME_WAIT" connections on the fast_cgi program
(1000 time_wait for 1500 connections). I activated the
tcp_time_wait_recycler, the time_wait connections decreased but the
problem is still there.

4- I tested 5 php-cgi and 20 php-cgi : the error rating is the same.

5- More traffic increase the number of errors.

Do you have an advice? A way to debug this problem?
Any help?

Thanks a lot!

-------------------------------------------------------

I use:
  . Nginx      0.6.32
  . PHP        5.1.6
  . MySQL      5.0.45
  . spawn-fcgi 1.4.19


My nginx.conf
----------------------------------------------------------
user              apache apache;
worker_processes  2;

events
{
   worker_connections  1024;
}


http
{
   include            mime.types;
   default_type       application/octet-stream;

   log_format         main             '$remote_addr [$time_local]
"$request" $status $body_bytes_sent "$http_referer"';
   access_log         logs/access.log  main;


   sendfile           on;
   keepalive_timeout  65;

   gzip               on;
   gzip_types         text/plain text/html text/css
application/x-javascript text/xml application/xml application/xml+rss
text/javascript;


   server
      {
         listen       80;
         server_name  localhost;

         root         /home/webmaster/www;


         location /
            {
               index  index.php;
               rewrite ^/?$                         /index.php
last;
               rewrite ^/?index\.php$               /index.php
last;
               rewrite ^/?page_number=([0-9]*)$
/index.php?page_number=$1     last;
               rewrite ^/?(.*)$                     /search.php?query=$1
last;
            }


         # PHP configuration
         location ~ .*\.php$
            {
               fastcgi_pass   127.0.0.1:9000;
               fastcgi_index  index.php;
               fastcgi_param  SCRIPT_FILENAME
/home/webmaster/www$fastcgi_script_name;
               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_param  SCRIPT_NAME        $fastcgi_script_name;
               fastcgi_param  REQUEST_URI        $request_uri;
               fastcgi_param  DOCUMENT_URI       $document_uri;
               fastcgi_param  DOCUMENT_ROOT      $document_root;
               fastcgi_param  SERVER_PROTOCOL    $server_protocol;
               fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
               fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;
               fastcgi_param  REMOTE_ADDR        $remote_addr;
               fastcgi_param  REMOTE_PORT        $remote_port;
               fastcgi_param  SERVER_ADDR        $server_addr;
               fastcgi_param  SERVER_PORT        $server_port;
               fastcgi_param  SERVER_NAME        $server_name;
               fastcgi_param  REDIRECT_STATUS    200;
            }


         # Static files configuration
         location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico)$
            {
               access_log        off;
               expires           30d;
            }
      }
}
-- 
Posted via http://www.ruby-forum.com/.





More information about the nginx mailing list