Today's job needs, to provide customers with a patch download address, so want to use the Nginx directory browsing function to do, need to let the customer see a directory to specify a list of files, and then let him choose to download that file;
We all know that under Apache can be configured to access a path to the Web server, automatically display the list of files below its directory, in fact, Nginx is not as weak as Apache, it can certainly achieve this function, but also very easy and simple; mainly used to AutoIndex This parameter is turned on and is configured as follows:
Copy Code code as follows:
Location/{
Root/data/www/file//Specify an absolute path to the actual directory;
AutoIndex on; Open Directory browsing function;
Autoindex_exact_size off; Close the detailed file size statistics, let the file size display MB,GB units, the default is B;
Autoindex_localtime on; Open to display file modification date in server local time zone!
}
When configured, use IE to access the server's root directory, it will show the/data/www/file directory of all Files list, Nginx directory browsing effect map:
In order to remember, and finally the Apache configuration method also recorded! Achieve the same effect as above!
Copy Code code as follows:
Alias/"/data/www/file"
< Directory "/data/www/file" >
Options Indexes//Open Directory list indexing mode
Order Allow,deny
Indexoptions namewidth = Charset = UTF-8//set filename display length, literal character encoding
Allow from all
</Directory >