方案1:重新编译,修改NGX_HTTP_AUTOINDEX_NAME_LEN
方案二:重新编译,采用fancyindex
下载插件
git clone --depth=1 https://ghproxy.com/https://github.com/aperezdc/ngx-fancyindex
git clone --depth=1 https://ghproxy.com/https://github.com/Naereen/Nginx-Fancyindex-Theme
编译nginx
yum install -y gcc zlib-devel pcre-devel openssl-devel
wget http://nginx.org/download/nginx-1.20.2.tar.gz
tar -xvf nginx-1.20.2.tar.gz
cd nginx-1.20.2
./configure --with-http_ssl_module --add-module=/root/ngx-fancyindex/
make -j4
make install
nginx.conf
cp /root/Nginx-Fancyindex-Theme/Nginx-Fancyindex-Theme-light /usr/local/nginx/html/ -r
location /Nginx-Fancyindex-Theme-light/ {
root html;
}
location / {
root /data;
fancyindex on;
fancyindex_localtime on;
fancyindex_exact_size off;
fancyindex_header "/Nginx-Fancyindex-Theme-light/header.html";
fancyindex_footer "/Nginx-Fancyindex-Theme-light/footer.html";
fancyindex_ignore "examplefile.html"; # Ignored files will not show up in the directory listing, but will still be public.
fancyindex_ignore "Nginx-Fancyindex-Theme-light"; # Making sure folder where files are don't show up in the listing.
# Warning: if you use an old version of ngx-fancyindex, comment the last line if you
# encounter a bug. See https://github.com/Naereen/Nginx-Fancyindex-Theme/issues/10
# fancyindex_name_length 255; # Maximum file name length in bytes, change as you like.
}