Welcome! Log In Create A New Profile


alternating 404 and 200

Nuno Magalhães
August 28, 2009 09:22AM

I've had this issue lately and i've been trying to find where did i
goof up but i'm getting clueless. I've recently compiled 0.8.10 (and a
few days before 0.8.9) on a Debian/linux amd64. Other than messing a
bit with the .deb i had no issues. These were the parameters i used:

--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--http-log-path=/var/log/nginx/access.log \
--http-client-body-temp-path=/var/lib/nginx/body \
--http-proxy-temp-path=/var/lib/nginx/proxy \
--http-fastcgi-temp-path=/var/lib/nginx/fastcgi \
--with-debug \
--with-http_stub_status_module \
--with-http_ssl_module \
--with-http_xslt_module \
--with-http_gzip_static_module \
--with-http_secure_link_module \
--add-module=/path/to/0.8.10/mod_strip \

I cleared /etc/nginx but i didn't touch other directories (like lib)
before installing 0.8.10, however, i don't think that would cause this
issue. Since i had been having these issues since before 0.8.9 i
decided to go with a spartan configuration:

$ cat /etc/nginx/nginx.conf

user www-data;
worker_processes 2;

error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;

events {
worker_connections 1024;

http {
root /var/www/nginx-default;
include /etc/nginx/mime.types;
default_type application/octet-stream;

#client_body_timeout 10;
#client_header_timeout 5;
#keepalive_timeout 5 5;
#send_timeout 10;

#limit_zone reqsPerClt $binary_remote_addr 1m;
#ignore_invalid_headers on;
#recursive_error_pages on;
#sendfile on;
#server_name_in_redirect off;
#server_tokens off;

#tcp_nodelay on;
#tcp_nopush on;

#gzip on;
#gzip_static on;
#gzip_buffers 32 8k;
#gzip_comp_level 9;
#gzip_http_version 1.0;
#gzip_min_length 25;
#gzip_types text/plain application/xhtml+xml text/css;
#gzip_vary on;

log_format vpt '[$time_local - $host] $remote_addr $remote_user [$request] '
'[T:$request_time S:$status BS:$body_bytes_sent GZ:$gzip_ratio]

include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;

Since this is my testing machine, i have no domains and test my sits
with subdirectories:

$ cat /etc/nginx/sites-available/default

server {
server_name localhost;
listen; # only in default rcvbuf=64k backlog=128;
access_log /var/log/nginx/localhost.access.log vpt;
error_log /var/log/nginx/localhost.error.log;
#limit_conn reqsPerClt 5;
charset utf-8;

#if ($request_method !~ ^(GET|HEAD|POST)$ ) {
# return 444;

location / {
root /var/www/nginx-default;
index index.php index.html;
#if (!-e $request_filename) {
# rewrite ^(.*)$ /index.php?m=$request_filename break;

#if ($request_uri ~*
) {
# break;
#return 444;

location = /favicon.ico {
return 204;

error_page 404 /40x.html;
location = /40x.html {
root /var/www/nginx-default;

error_page 403 /403.html;
location = /403.html {
root /var/www/nginx-default;

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /var/www/nginx-default;

location ~ \.(php|html)$ {
fastcgi_pass localhost:8888;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/nginx-default$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT /var/www/nginx-default;
fastcgi_intercept_errors on;
include fastcgi_params;

The issue is: if i reload repeatedly (hitting the reload button on my
browser repeatedly, at a rate of about 5-6 hits per second), under
given circumstances, half the time nginx will reply with a normal 200
(and 304 for static files), then for another half of the same time
it'll reply with the default 404 page (instead of the configured 404
page). Then 200, then 404, ... If i slow down the reloads, the 200-404
cycle slows down as well, and vice-versa.

- at my docroot i have a very basic index.html, just the necessary to
show <h1>Test</h1>. I can reload all i want, the issue seldom occurs.
- i have a very basic html+php site and, again, the issue seldom
occurs, usually just after i changed the URL from one site to another.
- i have another basic php+xhtml site. Reloading
/site3/index.php?param=value will give the aforementioned results
every time.

I haven't touched my fastcgi configuration (although i have upgraded
my system lately). I was fiddling with the .conf files at the time but
even going back to basic conf i still get this issue. I compiled from
source and installed using checkinstall but i don't think that would
interfere. So, i'm not sure this is because of nginx or my system, or
the 3rd site, or the fastcgi or what...

I'm kinda lost in finding where the hell did i screw up. Any hints?
Nuno Magalhães

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

alternating 404 and 200

Nuno Magalhães August 28, 2009 09:22AM

Re: alternating 404 and 200

Igor Sysoev August 28, 2009 10:58AM

Re: alternating 404 and 200

Nuno Magalhães September 02, 2009 05:49PM

Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 63
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready