W
W
Win32Sector2018-05-30 11:21:00
Nginx
Win32Sector, 2018-05-30 11:21:00

Why doesn't nginx list files in directories?

I don't understand what could be the problem.
There is a task using Nginx to publish several files. However, the list of directories is shown, but there are no files, while in the nginx error.log it is:

2018/05/30 07:33:38 [crit] 22491#22491: *1 stat() "/site/RPMS/file.txt" failed (13: Permission denied), client: 146.120.119.127, server: 35.207.49.222, request: "GET / HTTP/1.1", host: "35.207.49.222", referrer: "http://35.207.49.222/"

What I did: I took centos7, installed nginx on it,
cat /etc/nginx/conf.d/default.conf
server {
    listen       80;
    server_name  35.207.49.222;
    root /site/RPMS;

    location / {
        autoindex on;
   }
}

I tried to fix the rights to directories and files, now they are 755
namei -om /site/RPMS/file.txt


f: /site/RPMS/file.txt
  dr-xr-xr-x root  root  /
  drwxrwxrwx nginx nginx site
  drwxr-xr-x nginx nginx RPMS
  -rwxr-xr-x nginx nginx file.txt

But, if we go to 35.207.49.222 we will see that there are no files and 35.207.49.222/file.txt shows 403 Forbidden, although the file is there.
The process is running from nginx
ps aux | grep nginx
root     22490  0.0  0.1  46404   960 ?        Ss   07:33   0:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
nginx    22491  0.0  0.3  46788  2156 ?        S    07:33   0:00 nginx: worker process

What else can I try to fix so that nginx shows the files?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vadim, 2018-05-30
@Viji

Look. whether there are Execute rights on all parent directories... i.e. /site/RPMS/ and /site/

W
Win32Sector, 2018-06-08
@Win32Sector

In general, the problem was in crooked hands. I disabled Selinux in /etc/sysconfig/selinux and the server didn't restart. After the reboot everything worked.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question