The original post: /r/nginx by /u/PintSizeMe on 2024-12-01 21:13:15.

I’m having a problem getting nginx to serve files in a sub-directory rather than the root but I just get the nginx default at the root and not-found at /static.

server {
    listen        8446 default_server;
    server_name   web01;
    location /static {
        root /webfiles/staticfiles;
        autoindex on;
    }
}

However, if I use this I do get the files at the root as I’d expect. (the only difference is the location line)

server {
    listen        8446 default_server;
    server_name   web01;
    location / {
        root /webfiles/staticfiles;
        autoindex on;
    }
}

My goal is to share files from 4 different folders in 4 different sub-directories. I’ve been searching this off and on for months and now that it’s about time to build a replacement server I really want to get this solved rather than install Apache to do this again since Apache is overkill.

And I have autoindex on for troubleshooting and will drop it once I get things working.