nginx 500 error instead of 404

I have the following nginx configuration (at /etc/nginx/sites-available/default)

server {
    listen   80; ## listen for ipv4; this line is default and implied
    listen   [::]:80 default ipv6only=on; ## listen for ipv6

    root /usr/share/nginx/www;
    index index.php index.html index.htm;

    server_name _;

    location / {
            try_files $uri $uri/ /index.html;
    }

    error_page 404 /404.html;

    location ~ \.php$ {
            try_files $uri =404;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass unix:/tmp/php5-fpm.sock;
            fastcgi_index index.php;
            include fastcgi_params;
    }

    location ~ /\.ht {
            deny all;
    }
}

Instead of a 404 error, I'm getting 500 server errors on broken urls. How can I correct this?


Solution 1:

It is most likely due to the way the location / block works. Please change it as follows...

location / {
    try_files $uri $uri/ =404;
}