I. Introduction to the Ngx-fancyindex module:
Nginx Web server's own directory browsing function does not look so beautiful, we can use the Ngx-fancyindex plugin to beautify the directory browsing function.
We go to Https://github.com/aperezdc/ngx-fancyindex to download Ngx-fancyindex
Two. Install the Nginx third-party module without nginx installation:
#tar XF nginx-1.8.0.tar.gz
#unzip Ngx-fancyindex-master.zip
#cd nginx-1.8.0/
#./configure--prefix=/usr/local/nginx--with-http_stub_status_module--with-http_image_filter_module--user=nginx --group=nginx--with-http_ssl_module--add-module=. /ngx-fancyindex-master
PS:--add-module= directory path for third-party modules
#make && make Install
Three. Install the Ngx-fancyindex module in the case where Nginx is already installed:
#tar XF nginx-1.8.0.tar.gz
#unzip Ngx-fancyindex-master.zip
#cd nginx-1.8.0/
#./configure--prefix=/usr/local/nginx--with-http_stub_status_module--with-http_image_filter_module--user=nginx --group=nginx--with-http_ssl_module--add-module=. /ngx-fancyindex-master
#make # #不要make Install
#cp/objs/nginx/usr/local/nginx/sbin/# #复制重新编译的nginx文件到nginx原来安装目录下
PS: Installing nginx third-party module is actually using--add-module to reinstall the Nginx, do not make install but directly to the compilation directory objs/ Nginx files directly overwrite the old nginx files. If you need to install more than one Nginx third-party module, you only need to specify several corresponding--add-module. When recompiling, remember to add the previously compiled modules to the Configure parameter.
Nginx provides a very many nginx third-party modules for installation, address Http://wiki.nginx.org/3rdPartyModules
four. Ngx-fancyindex configuration
location /ftp {
fancyindex on;
Fancyindex_exact_size off;
fancyindex_localtime on;
fancyindex_footer "footer.html";
auth_basic "Restricted";
auth_basic_user_file "/etc/nginx/ . htpasswd ";
Fancyindex on: Whether to open Fancyindex index
Fancyindex_exact_size off:: Do not use exact size, use rounding, 1.9M will be displayed as 2M. If enabled, the unit is byte
Fancyindex_localtime on: Using local time
Fancyindex_footer "footer.html": the footer.html content under the current path as the bottom.
Fancy instructions use:
Fancyindex
Syntax: *fancyindex* [*on* | *off*]
Default value: Fancyindex off
Configuration block: HTTP, server, location
Description: Turn on/Off the directory indexing feature
Fancyindex_css_href
Syntax: *fancyindex_css_href uri*
Default value: Fancyindex_css_href ""
Configuration block: HTTP, server, location
Description: External CSS path, this CSS will replace the existing CSS style.
Fancyindex_exact_size
Syntax: *fancyindex_exact_size* [*on* | *off*]
Default value: Fancyindex_exact_size on
Configuration block: HTTP, server, location
Description: Defines how the file size is displayed, by default On,on: The file size uses an exact value in bytes. Off: Unit is KB,MB,GB, and if it contains a decimal point, it will be rounded. For example, 1.9MB, it will be displayed as 2MB.
Fancyindex_footer
Syntax: *fancyindex_footer path*
Default value: Fancyindex_footer ""
Configuration block: HTTP, server, location
Description: Specifies which file is embedded at the bottom of the index page
Fancyindex_header
Syntax: *fancyindex_header path*
Default value: Fancyindex_header ""
Configuration block: HTTP, server, location
Description: Specifies which file is embedded in the header of the index page. Usage is similar to Fancyindex_footer
Fancyindex_ignore
Syntax: *fancyindex_ignore string1 [string2 [... stringn]]*
Default value: No default.
Configuration block: HTTP, server, location
Description: Which files/directories are hidden, and if your nginx supports regular, then you can use regular expressions to filter
For example, I want to hide the dir file or directory and the file File1.txt, configured as follows:
Fancyindex_ignore "dir*" "file1.txt"
Fancyindex_localtime
Syntax: *fancyindex_localtime* [*on* | *off*]
Default value: Fancyindex_localtime off
Configuration block: HTTP, server, location
Description: Use local time to display file creation time, default is off (GMT time)
This article is from "Luo Chen's blog" blog, please be sure to keep this source http://luochen2015.blog.51cto.com/9772274/1696301
Nginx third-party module Ngx-fancyindex installation