nginx配置文件下载并且目录展示

1.windows

2.路径如D:/im-az/server/download

下面有各种文件

3.配置

location /download {
			root D:/im-az/server;
			autoindex on; # 开启目录浏览功能
            autoindex_format html; #以html风格将目录展示在浏览器中
            autoindex_exact_size off; #切换为 off 后,以可读的方式显示文件大小,单位为 KB、MB 或者 GB
            autoindex_localtime on; #以服务器的文件时间作为显示的时间
            
            #符合条件,直接下载
            if ($request_filename ~* ^.*?\.(txt|doc|pdf|rar|gz|zip|docx|exe|xlsx|ppt|pptx)$){
               add_header Content-Disposition attachment;
            }
		}

nginx配置文件下载并且目录展示_第1张图片

 

你可能感兴趣的:(nginx,运维)