<!-- review: finished -->

<a id="http-autoindex"></a>

# AutoIndex

Serves requests ending with a slash (`/`) and produces a directory listing. Usually, a request is passed to the `AutoIndex` module when the [Index](https://en.angie.software//angie/docs/configuration/modules/http/http_index.md#http-index) module cannot find an index file.

<a id="configuration-example-8"></a>

## Configuration Example

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

<a id="directives-9"></a>

## Directives

<a id="index-0"></a>

<a id="id1"></a>

### autoindex

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `autoindex` `on` | `off`;   |
|------------------------------------------------------------------------------------------|-----------------------------|
| Default                                                                                  | `autoindex off;`            |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location      |

Enables or disables the directory listing output.

<a id="index-1"></a>

<a id="autoindex-exact-size"></a>

### autoindex_exact_size

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `autoindex_exact_size` `on` | `off`;   |
|------------------------------------------------------------------------------------------|----------------------------------------|
| Default                                                                                  | `autoindex_exact_size on;`             |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location                 |

For the HTML [format](#autoindex-format), specifies whether exact file sizes should be output in the directory listing, or rather rounded to kilobytes, megabytes, and gigabytes.

<a id="index-2"></a>

<a id="autoindex-format"></a>

### autoindex_format

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `autoindex_format` `html` | `xml` | `json` | `jsonp`;   |
|------------------------------------------------------------------------------------------|---------------------------------------------------------|
| Default                                                                                  | `autoindex_format html;`                                |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location                                  |

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.

The XML output can be transformed using the [XSLT](https://en.angie.software//angie/docs/configuration/modules/http/http_xslt.md#http-xslt) module.

### Output Formats

Object fields in responses contain the following data:

| Field   | Description                                                                                       |
|---------|---------------------------------------------------------------------------------------------------|
| `name`  | File or directory name                                                                            |
| `type`  | Object type: `file` or `directory`                                                                |
| `size`  | Object size according to [autoindex_exact_size](#autoindex-exact-size);<br/>for directories — `0` |
| `mtime` | Last modification time in Unix time format                                                        |

HTML

```html
<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

```xml
<?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>
```

JSON

```json
[
{
    "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"
}
]
```

JSONP

```javascript
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"
}
]);
```

<a id="index-3"></a>

<a id="autoindex-localtime"></a>

### autoindex_localtime

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `autoindex_localtime` `on` | `off`;   |
|------------------------------------------------------------------------------------------|---------------------------------------|
| Default                                                                                  | `autoindex_localtime off;`            |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location                |

For the HTML [format](#autoindex-format), specifies whether times in the directory listing should be output in the local time zone or UTC.
