UPDATED nginx.conf FILE AND ANYTHING ELSE TO THE LATEST STATE
BUT STILL GETTING 404 ERRORS 🙁
So i was trying to setup directory listing on my server with nginx, i followed the instructions step-by-step but nothing worked out — always popping either 403 or 404 errors while permissions are all set to 755…
When i enable autoindex on the root location it worked fine, but when i put it on the "dl/" location, it either shows a 404 when requesting /dl or 403 when requesting /dl/
After i followed @Bryce Larson's steps…403 is gone now only 404 is there…which is still not okay…
# pwd
/root/Downloads/dl
# ls -lha
total 12K
drwxr-xr-x 2 nginx root 4.0K Nov 25 20:01 .
drwxr-xr-x 4 root root 4.0K Nov 26 09:11 ..
-rwxr-xr-x 1 nginx root 26 Nov 25 20:01 blah.txt
Here's the nginx.conf
:
https://0bin.net/paste/he2oIb2OFou4G9Fd#v5qt5M7scM8jlSRkl9B+GepP+PoInAHrfZrJNJ7Ch9U
I'm gonna use 0bin for long code/config etc to save time&effort, plus it's got syntax coloring 😉
And yeah i've restarted nginx a hundred times just to make sure it takes the new config…so what's wrong now?
Otherwise, how would you configure the nginx server for this purpose? — your own nginx.conf files are welcomed plz paste it here: https://0bin.net
Best Answer
I eventually found the solution myself X-(
So to specify the
location
with root, ur gonna have to specify the parent directory instead of the directory that ur planning to serve (which is pretty obvious now that i think of it -- it's the god damn root!).So as in my example i should specify
/root/Downloads
with the root parameter, then the server is gonna try to find a dir nameddl
within it.I did recall trying this way but the permission issues as mentioned by @Bryce Larson could be the reason why it didn't succeed.
Here's the final
nginx.conf
in case people are interested.The correct way to setup directory listing in nginx is to
A. specify the parent directory of the directory that ur trying to serve.
B. make sure the permissions from
/
all the way to the directory that ur trying to serve is set executable, i.echmod +X -R .