1

I am trying to make my subpath as directory listing only in Nginx, however it returns 404.

Suppose I have following config for http://file.example.com/test:

server {
    listen        80;
    server_name  file.example.com;

    location /test/ {
        root    /var/www/abc/def/;
        autoindex on;
        autoindex_exact_size off;
        autoindex_format html;
        autoindex_localtime on;
    }
}

I didn't specify / section, is it the issue caused above not working? Anything I missed?

Jerry Bian
  • 3,998
  • 6
  • 29
  • 54

1 Answers1

2

Change the location to location /test

Copy all your files to /var/www/abc/def/test folder, because you are using location directive along with root directive. In your case when Nginx searching static files, it will use the root path /var/www/abc/def and append with location path /test.

Or use alias as @RichardSmith suggested.

mgsxman
  • 676
  • 5
  • 11