I just installed nginx on ubuntu 12.04 LTS. When i access localhost it gives me :

500 Internal Server Error nginx/1.2.3

error_log has following

rewrite or internal redirection cycle while internally redirecting to "/index.html", client:, server: localhost, request: "GET / HTTP/1.1", host: "localhost"

This is default nginx configuration: nginx.conf has:

    include /etc/nginx/sites-enabled/*;

/etc/nginx/sites-enabled/default has following

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

    # Make site accessible from http://localhost/
    server_name localhost;
    location / {
            # First attempt to serve request as file, then
            # as directory, then fall back to displaying a 404.
            try_files $uri $uri/ /index.html;
            # Uncomment to enable naxsi on this location
            # include /etc/nginx/naxsi.rules
  • Welcome to Server Fault. While we're pretty good sysadmins, we can neither read your mind nor your monitor. Please provide as much detail as possible when asking your questions. In this case, your nginx configuration would be necessary to figure out what's going on. Use the edit link to edit your question and provide the missing information. – Michael Hampton Aug 29 '12 at 3:53
  • 1
    possible duplicate of Nginx 1.2.2: How to get try_files to work? – quanta Aug 29 '12 at 5:00
  • I would post this as an answer, but I'm not sure it is: have you tried putting an index.html, even just a basic one, in the document root? – pjmorse Sep 18 '12 at 1:45

Nginx changed the default site directly name from www to html.

root /usr/share/nginx/www;

Should be changed to

root /usr/share/nginx/html;

  • This worked for me as well. found in /etc/nginx/sites-enabled/default – Stephanie Oct 26 '12 at 1:21

You don't need the location block and the try_files at all for this simple configuration.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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