5

I'm having trouble with nginx and autoindex.

Even though I've put it in the site-host, it's still throwing "403 -Forbidden at me"

     location /pics {
             autoindex on;              
     }

is what I have as an config

        server {

        listen   80;
        server_name www.domain.com;

        access_log /home/www/log/access.log;
        error_log /home/www/log/error.log;

        location / {

                    root   /home/www/public/;
                    index  index.html index.php;
                    }

        location    /pics {
                    autoindex on;
                     }
              }

I've checked nginx -v and has been built with the autoindex module. Just getting clueless here.

8

The root set in location / does not apply to location /pics, so if you check your error log, you'll see that nginx is looking in the default root for requests to /pics. Just remove the location / and set the root and index directives in the server context:

server {
  root /home/www/public;
  index index.html index.php;

  location /pics {
    autoindex on;
  }
}

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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