alternating 404 and 200

Nuno Magalhães nunomagalhaes at
Wed Sep 2 15:27:24 MSD 2009

I'm sorry, i didn't notice your reply (too many mailing lists and a
web client...).

2009/8/28 Igor Sysoev <is at>:

> Do you see these 404's in access_log and error_log ?

Yes, both the 200 (and following 304) and the 404 error show up in the
access log. I had forgotten about the error log! Turns out the 404 are
because there was no 50x.html, which is now displayed instead of my
custom 404 page. So the true error is 502 but i'm not running nginx as
a proxy, it's the only http server.

The error is this:
2009/09/02 12:03:32 [error] 8296#0: *79 recv() failed (104: Connection
reset by peer) while reading response header from upstream, client:, server: localhost, request: "GET
/subfolder/index.php?var=param HTTP/1.1", upstream:
"fastcgi://", host: "localhost:8080", referrer:

Although i kind of suspected it (because a simple html file didn't do
this), i didn't assume cgi would be the problem since i haven't
touched its configuration in ages. I did upgrade my Debian, and the
/etc/nginx/fastcgi_params was indeed replaced to the default. However,
i (think i) had only removed $nginx_version from SERVER_SOFTWARE, but
i'm not sure.

This is the current:
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;

# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param  REDIRECT_STATUS    200;

(I actually don't know if PHP was built with that, but i assume
phpinfo() and finding text will answer.)

My current nginx is compiled from 0.8.10 source although i used some
files from the Debian package (for logrotate, pre/post-install
scripts, boot scripts and what not), creating a new .deb package (with
checkinstall). Maybe that interfered with the system upgrade and or
nginx/php-cgi configurations.

I'm probably overflowing some buffer of filling some cache or
something on cgi. How can i solve this?

While i was trying to figure out if it was nginx or php i installed
Apache, which ended up confusing me even more... Anyway, i have the
following directories in /var/www: apache, nginx_default, site01. I
changed my nginx.conf and my server{ } so that both have root /var/www
and restarted nginx (i've also tried stop/start). I use URLs like
"http://localhost:8080/site01", but nginx is still serving the site
from /var/www/nginx_default/site01, not /var/www/site01 as i expected.
What am i doing wrong this time? :)

I'm sorry i didn't check the error.log sooner. thanks for your help.
Nuno Magalhães

()  ascii-rubanda kampajno - kontraŭ html-a retpoŝto
/\  ascii ribbon campaign - against html e-mail

More information about the nginx mailing list