Nginx default is not allowed to list the entire directory. For this feature, open the nginx.conf file or you want to enable directory browsing virtual host configuration file, add AutoIndex on to the server or location segment, and enable directory traffic, as described below.
In addition Nginx directory traffic has two more useful parameters, can be added according to their own needs:
Autoindex_exact_size off;
The default is on to show the exact size of the file, in bytes.
After change to off, the approximate size of the file is displayed, in kilobytes or MB or GB
Autoindex_localtime on;
The default is off, and the file time displayed is GMT time.
When on, the file time displayed is the server time of the file
1, the entire virtual host to open directory traffic
Add in Server segment
Location/{
AutoIndex on;
Autoindex_localtime on; #之类的参数写这里
}
2. Open Directory traffic in a separate directory
2.1: Direct two-level directory to open Directory traffic
location/down/{
AutoIndex on;
}
2.2: Virtual directory to open Directory traffic
location/down/{
alias/home/wwwroot/lnmp/test/;
AutoIndex on;
}
Detailed reference: http://nginx.org/en/docs/http/ngx_http_autoindex_module.html
If you want to make a beautiful directory listing, support Header,footer can install the three-party plugin:
Http://wiki.nginx.org/NginxNgxFancyIndex
Restart the nginx to make it effective.
This article is from the "Smurf Linux ops" blog, so be sure to keep this source http://jin771998569.blog.51cto.com/2147853/1670327
Nginx Open Directory browsing function (AutoIndex)