May 06, 2011 09:38AM
I'm setting up a new nginx environment and I'm having issues with 404's. When I use curl to request a file that I know does not exist, nginx responds back with an empty reply.... I would prefer a 404 not found with the correct http status code.

My config:

user nobody;
worker_processes 4;
worker_rlimit_nofile 8192;
worker_connections 4096;

include mime.types;
default_type text/plain;
log_format nn '$host $remote_addr - $remote_user [$time_local] ' '"$request" $status $bytes_sent ' '"$http_referer" "$http_user_agent"';
access_log /opt/nginx/logs/access.log nn;
error_log /opt/nginx/logs/error.log;
sendfile on;
keepalive_timeout 0;
listen 80 default;
root /opt/nginx/html/;
index index.html index.htm index.php index.php5;
include /opt/nginx/conf/location_php.conf;
include /opt/nginx/conf/vhosts/*.conf;

The html root dir:

bash> ls /opt/nginx/html/
404.html 50x.html empty.html foobar index.html ping

The curl request:

curl -v http://localhost/index.html2
* About to connect() to localhost port 80
* Trying connected
* Connected to localhost ( port 80
> GET /index.html2 HTTP/1.1
> User-Agent: curl/7.15.5 (i386-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
> Host: localhost
> Accept: */*
* Empty reply from server
* Connection #0 to host localhost left intact
curl: (52) Empty reply from server
* Closing connection #0

The access log:
localhost - - [06/May/2011:09:35:17 -0400] "GET /index.html2 HTTP/1.1" 200 0 "-" "curl/7.15.5 (i386-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5" - For some reason returning http status code 200?

The error log:
2011/05/06 09:35:17 [error] 9879#0: *9312 open() "/opt/nginx/html/index.html2" failed (2: No such file or directory), client:, server: , request: "GET /index.html2 HTTP/1.1", host: "localhost"

I don't understand what I'm doing wrong here... any thoughts?
Subject Author Posted

empty reply from server

yellowbox9 May 06, 2011 09:38AM

Re: empty reply from server

Maxim Dounin May 07, 2011 06:36PM

Re: empty reply from server

yellowbox9 May 09, 2011 01:18PM

Re: empty reply from server

Liu Lantao May 16, 2011 12:42AM

Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 97
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready