0
点赞
收藏
分享

微信扫一扫

CentOS解决nginx autoindex 截断文件名,末尾出现乱码

年迈的代码机器 2022-01-24 阅读 65

方案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.

    }

 

举报

相关推荐

0 条评论