Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
    
I'm just going to leave this here and hope someone will find it useful: wiki.nginx.org/NginxHttpMainModule#error_log –  tfitzgerald Jun 19 '12 at 3:12

1 Answer 1

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

    location / {
            try_files $uri $uri/ =404;
    }
share|improve this answer
    
When I changed that line, I no longer see a 500 error at broken URL's. However, I'm seeing my index.php page instead of 404.html. –  arby Jun 19 '12 at 17:49
    
I am updating my answer now to display 404.html for broken URLs correctly. Thanks. –  Pothi Jun 20 '12 at 0:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.