nginx文件服务器html美化,Nginx浏览目录配置及美化

https://segmentfault.com/a/1190000012606305

在项目中有一个功能需要在浏览器页面中浏览服务器的目录。服务器使用Nginx,而Nginx提供了相应的ngx_http_autoindex_module 模块,该模块提供了我们想要的功能。

Nginx ngx_http_autoindex_module 模块

该模块有以下几个命令:

命令

默认值

值域

作用域

EG

autoindex

off

on:开启目录浏览;

off:关闭目录浏览

http, server, location

autoindex on;打开目录浏览功能

autoindex_format

html

html、xml、json、jsonp 分别用这几个风格展示目录

http, server, location

autoindex_format html; 以网页的风格展示目录内容。该属性在1.7.9及以上适用

autoindex_exact_size

on

on:展示文件字节数;

off:以可读的方式显示文件大小

http, server, location

autoindex_exact_size off; 以可读的方式显示文件大小,单位为 KB、MB 或者 GB,autoindex_format为html时有效

autoindex_localtime

off

on、off:是否以服务器的文件时间作为显示的时间

http, server, location

autoindex_localtime on; 以服务器的文件时间作为显示的时间,autoindex_format为html时有效

浏览目录基本配置

根据上面的命令,一个简单的Nginx浏览目录的配置如下:

location /download { root /home/map/www/; #指定目录所在路径 autoindex on; #开启目录浏览 autoindex_format html; #以html风格将目录展示在浏览器中 autoindex_exact_size off; #切换为 off 后,以可读的方式显示文件大小,单位为 KB、MB 或者 GB autoin

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值