# ngx\_http\_autoindex\_module

* [示例配置](/nginx-docs/he-xin-gong-neng/http/ngx_http_autoindex_module.md#example_configuration)
* [指令](/nginx-docs/he-xin-gong-neng/http/ngx_http_autoindex_module.md#directives)
  * [autoindex](/nginx-docs/he-xin-gong-neng/http/ngx_http_autoindex_module.md#autoindex)
  * [autoindex\_exact\_size](/nginx-docs/he-xin-gong-neng/http/ngx_http_autoindex_module.md#autoindex_exact_size)
  * [autoindex\_format](/nginx-docs/he-xin-gong-neng/http/ngx_http_autoindex_module.md#autoindex_format)
  * [autoindex\_localtime](/nginx-docs/he-xin-gong-neng/http/ngx_http_autoindex_module.md#autoindex_localtime)

`ngx_http_autoindex_module` 模块处理以斜线字符（`/`）结尾的请求并生成一个目录列表。当 [ngx\_http\_index\_module](/nginx-docs/he-xin-gong-neng/http/ngx_http_index_module.md) 模块找不到索引文件时，通常会将请求传递给 `ngx_http_autoindex_module` 模块。

## 示例配置 <a href="#example_configuration" id="example_configuration"></a>

```
location / {
    autoindex on;
}
```

## 指令 <a href="#directives" id="directives"></a>

### autoindex

| -       | 说明                           |
| ------- | ---------------------------- |
| **语法**  | **autoindex** `on` \| `off`; |
| **默认**  | autoindex off;               |
| **上下文** | http、server、location         |

启用或禁用目录列表输出。

### autoindex\_exact\_size

| -       | 说明                                        |
| ------- | ----------------------------------------- |
| **语法**  | **autoindex\_exact\_size** `on` \| `off`; |
| **默认**  | autoindex\_exact\_size on;                |
| **上下文** | http、server、location                      |

对于 HTML [格式](/nginx-docs/he-xin-gong-neng/http/ngx_http_autoindex_module.md#autoindex_format)，指定是否应在目录列表中输出确切的文件大小，或者四舍五入到千字节、兆字节和千兆字节。

### autoindex\_format

| -       | 说明                                                          |
| ------- | ----------------------------------------------------------- |
| **语法**  | **autoindex\_format** `html` \| `xml` \| `json` \| `jsonp`; |
| **默认**  | autoindex\_format html;                                     |
| **上下文** | http、server、location                                        |
| **提示**  | 该指令在 1.7.9 版本中出现                                            |

设置目录列表的格式。

当使用 JSONP 格式时，使用 `callback` 请求参数设置回调函数的名称。如果没有参数或为空值，则使用 JSON 格式。

XML 输出可以使用 [ngx\_http\_xslt\_module](/nginx-docs/he-xin-gong-neng/http/ngx_http_xslt_module.md) 模块进行转换。

### autoindex\_localtime

| -       | 说明                                      |
| ------- | --------------------------------------- |
| **语法**  | **autoindex\_localtime** `on` \| `off`; |
| **默认**  | autoindex\_localtime off;               |
| **上下文** | http、server、location                    |

对于 HTML [格式](/nginx-docs/he-xin-gong-neng/http/ngx_http_autoindex_module.md#autoindex_format)，指定目录列表中的时间是否应使用本地时区或 UTC 输出。

## 原文档

<http://nginx.org/en/docs/http/ngx_http_autoindex_module.html>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docshome.gitbook.io/nginx-docs/he-xin-gong-neng/http/ngx_http_autoindex_module.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
