AutoIndex#
该模块处理以斜杠字符 ( 启用或禁用目录列表输出。 对于 HTML 格式,指定目录列表中是否输出精确的文件大小,或者将其四舍五入到千字节、兆字节和千兆字节。 设置目录列表的格式。 当使用 JSONP 格式时,回调函数的名称通过 XML 输出可以通过 XSLT 模块进行转换。 输出格式 响应中的对象字段包含以下数据: 字段 描述 文件或目录名称 对象类型: 根据 autoindex_exact_size 的对象大小;
对于目录 — Unix 时间格式的最后修改时间 对于 HTML 格式,指定目录列表中的时间是以本地时区还是以 UTC 输出。/
) 结尾的请求,并生成目录列表。通常,当 Index 模块找不到索引文件时,请求会传递给 AutoIndex
模块。配置示例#
location / {
autoindex on;
}
指令#
autoindex#
autoindex_exact_size#
autoindex_format#
callback
请求参数设置。如果参数缺失或为空值,则使用 JSON 格式。name
type
file
或 directory
size
0
mtime
<html>
<head>
<title>Index of /files/</title>
</head>
<body>
<h1>Index of /files/</h1>
<hr>
<pre>
<a href="../">../</a>
<a href="example.txt">example.txt</a> 12-Jun-2025 14:21 1234
<a href="image.png">image.png</a> 12-Jun-2025 14:21 4321
</pre>
<hr>
</body>
</html>
<?xml version="1.0" encoding="UTF-8"?>
<listing>
<file>
<name>example.txt</name>
<type>file</type>
<size>1234</size>
<mtime>2025-06-12T14:21:00Z</mtime>
</file>
<file>
<name>image.png</name>
<type>file</type>
<size>4321</size>
<mtime>2025-06-12T14:21:00Z</mtime>
</file>
</listing>
[
{
"name": "example.txt",
"type": "file",
"size": 1234,
"mtime": "2025-06-12T14:21:00Z"
},
{
"name": "image.png",
"type": "file",
"size": 4321,
"mtime": "2025-06-12T14:21:00Z"
}
]
callback([
{
"name": "example.txt",
"type": "file",
"size": 1234,
"mtime": "2025-06-12T14:21:00Z"
},
{
"name": "image.png",
"type": "file",
"size": 4321,
"mtime": "2025-06-12T14:21:00Z"
}
]);
autoindex_localtime#