Указатель каталога Nginx 403 для папки / some / запрещен - PullRequest
0 голосов
/ 27 ноября 2018

я хочу использовать nginx для просмотра файлов (как в проводнике файлов - не иметь index.html)

folder / opt / chocolatey content:

find
.

./ccleaner
./ccleaner/ccsetup549.exe

файл конфигурации:

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
    worker_connections 1024;
}

http {
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 2048;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    include /etc/nginx/conf.d/*.conf;

    server {
        listen       80 default_server;
        listen       [::]:80 default_server;
        server_name  _;
        #root         /usr/share/nginx/html;
        root          /opt/chocolatey/;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        #location / {
        #}

        location / {
           root /opt/chocolatey/;
          autoindex on;
    }


        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }

Права доступа: chmod 755 / opt / chocolatey / * chown -R nginx: nginx / opt / chocolatey

ls -ls
total 4
4 drwxr-xr-x. 4 nginx nginx 4096 Nov 27 08:29 chocolatey

В файле error.log:

запрос:"GET / HTTP / 1.1", хост: "192.168.1.13" 2018/11/27 08:44:21 [ошибка] 9733 # 0: * 2 индекс каталога "/ opt / chocolatey /" запрещен

Selinux отключен

Set chmod -R o+x /opt/chocolatey

1 Ответ

0 голосов
/ 27 ноября 2018

Решено: пришлось изменить конфигурационный файл:

Удалено:

location / {
           root /opt/chocolatey/;
          autoindex on;
    }

добавлено

        root          /opt/chocolatey/;
        autoindex      on;

Под директивами сервера {}

...