zl程序教程

您现在的位置是:首页 >  前端

当前栏目

重识Nginx - 08 使用ngx_http_autoindex_module实现目录浏览功能

NginxHTTP 实现 使用 功能 目录 浏览 module
2023-06-13 09:13:43 时间

文章目录

ngx_http_autoindex_module

https://nginx.org/en/docs/http/ngx_http_autoindex_module.html


配置

Example Configuration

location / {
    autoindex on;
}

autoindex

Syntax:	autoindex on | off;
Default:	
autoindex off;
Context:	http, server, location

Enables or disables the directory listing output.

autoindex on; 设置为on目录是可以访问的 autoindex off; 设置为off目录禁止访问,里面具体内容是可以访问的。


autoindex_exact_size

autoindex_exact_size off; 默认为on,显示出文件的确切大小,单位是bytes。 改为off后,显示出文件的大概大小,单位是kB或者MB或者GB

Syntax:	autoindex_exact_size on | off;
Default:	
autoindex_exact_size on;
Context:	http, server, location

For the HTML format, specifies whether exact file sizes should be output in the directory listing, or rather rounded to kilobytes, megabytes, and gigabytes.


autoindex_localtime

autoindex_localtime on; 默认为off,显示的文件时间为GMT时间。 改为on后,显示的文件时间为文件的服务器时间

Syntax:	autoindex_localtime on | off;
Default:	
autoindex_localtime off;
Context:	http, server, location

For the HTML format, specifies whether times in the directory listing should be output in the local time zone or UTC.


autoindex_format

Syntax:	autoindex_format html | xml | json | jsonp;
Default:	
autoindex_format html;
Context:	http, server, location
This directive appeared in version 1.7.9.

Sets the format of a directory listing.

When the JSONP format is used, the name of a callback function is set with the callback request argument. If the argument is missing or has an empty value, then the JSON format is used.


实操

访问