Nginx打开目录浏览功能

nginx.conf 配置文件添加如下内容

    server {
        listen       80;
        server_name  localhost;
        add_header Access-Control-Allow-Origin *;
        add_header Access-Control-Allow-Headers X-Requested-With;
        add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
        #charset koi8-r;
        
        #access_log  logs/host.access.log  main;

        location / {
            root   E:\sharefolder;
            #文件夹根目录
            autoindex on;
            #打开目录浏览功能
            autoindex_exact_size off;
            #默认为on,显示出文件的确切大小,单位是bytes。改为off后,显示出文件的大概大小,单位是kB或者MB或者GB
            autoindex_localtime on;
            #默认为off,显示的文件时间为GMT时间。改为on后,显示的文件时间为文件的服务器时间
        }
        location /noshare {
            root   E:\sharefolder\noshare;
            deny all;
            return 403;
            #拒绝访问noshare目录,返回403
        }

Was this article helpful?

Related Articles