繁体   English   中英

/some/folder 的 Nginx 403 目录索引被禁止

[英]Nginx 403 directory index of /some/folder is forbidden

我想使用 nginx 进行文件浏览(就像在文件浏览器中一样 - 没有 index.html)

文件夹 /opt/chocolatey 内容:

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 文件中:

request: "GET / HTTP/1.1", host: "192.168.1.13" 2018/11/27 08:44:21 [error] 9733#0: *2 目录索引 "/opt/chocolatey/" 被禁止

Selinux 已禁用

设置chmod -R o+x /opt/chocolatey

已解决:必须更改配置文件:

删除:

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

添加

        root          /opt/chocolatey/;
        autoindex      on;

在 server { } 指令下

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM