Search code examples
permissionsnginxhttp-status-code-403

Nginx: example.com works; example.com/folder gets 403 Forbidden


I just set up Nginx for the first time, having liked what I read about its advantages over Apache.

My problem is this: I start up Nginx on my Linux Mint (12, 32-bit) box. index.html is located at

/usr/share/nginx/www

I also have a folder located at

/usr/share/nginx/www/store

which contains some ISO files, but no html files (so there is not even an index.html). In Apache, this would result in a folder directory, and I'm hoping to get something similar from Nginx -- I thought that was a basic functionality feature.

It is worth noting that

/usr/share/nginx/www/store

is a mounting point that I use for a Samba share.

Here's the problem:

I go to access my Linux box from my other machine. By going to www.example.com, I am greeted with the standard "Welcome to nginx" message. When I go to www.example.com/store, I get a "403 Forbidden" error instead of a directory listing of the files in /store.

I've read lots about permissions being the cause of 403 errors, but I don't see how I could've missed anything. In mild desperation, I edited nginx.conf to say

user root;

so nginx is running as root, even though I know that's not the best idea (I just wanted to see if it was a permissions issue). Both usr/share/nginx/www and usr/share/nginx/www/store (as well as the ISO files contained therein) have permissions drwxr-xr-x and are owned by root root. The Samba server works just fine, and I have full access to /store from my other computer, but I can't get at it from a browser.

Any ideas?


Solution

  • You need to set the autoindex configuration to 'on' in the nginx server configuration. Ex:

    location  /  {
      autoindex  on;
    }
    

    By default the value is OFF

    Ref: http://wiki.nginx.org/HttpAutoindexModule