您的位置:首页 > 运维架构 > Nginx

nginx开启目录浏览下载功能(autoindex)

2017-01-11 15:44 519 查看

HTTP目录清单生成模块(HTTP Auto Index)

·摘要

这个模块提供自动目录列表。

连接请求仅在ngx_http_index_module中没有找到主页文件时才会请求这个模块。

              location / {  

                        autoindex on; #开启目录浏览下载功能

                                    }

二级目录时也可以使用此功能 

                       localtion /download/{

                           autoindex on; #开启目录浏览下载功能

                           autoindex_exact_size off;#指定文件大小显示为M默认是b

                           autoindex_localtime on;  #开启以服务器本地时区显示文件修改日期  默认为 off,以 GMT 时间作为显示的文件时间;  

                           alias /home/test/;

                        }

配置完成后,保存,重启nginx通过浏览器访问该路径时,会有如下效果。

指令:

autoindex

语法:autoindex [ on|off ]

默认值:autoindex off

使用字段:http, server, location

是否使用自动目录列表。


autoindex_exact_size

语法:autoindex_exact_size [ on|off ]

默认值:autoindex_exact_size on

使用字段:http, server, location

指定生成的自动目录文件大小,可以是精确到bytes或者使用KB, MB或GB。


autoindex_localtime

语法:autoindex_localtime [ on|off ]

默认值:autoindex_localtime off

使用字段:http, server, location

是否在目录列表文件中显示本地时间(GMT时间),默认为关。

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  nginx