7

I'm completely new to nginx. I've installed nginx on windows pc.

What I want to do is server a list of files in D:\ on localhost:8082/list.

If I use the following conf:

server {
    listen       8082;

    location / {
        root D:/;
        autoindex on;
    }
}

I can correctly see what i want on localhost:8082. But if I change it to:

server {
    listen       8082;

    location /list {
        root D:/;
        autoindex on;
    }
}

The page localhost:8082/list gives a 404 error.

imlokesh
  • 2,506
  • 2
  • 22
  • 26

1 Answers1

12

What you need is alias instead of root.

server {
    listen       8082;

    location /list {
        alias D:/; ##### use alias, not root
        autoindex on;
    }
}

See Nginx -- static file serving confusion with root & alias

Anand Bhat
  • 5,591
  • 26
  • 30