# ngx\_http\_random\_index\_module

`ngx_http_random_index_module` 模块处理以 `/` 结尾的请求，然后随机选择目录中的一个文件作为索引文件展示，该模块优先于 [ngx\_http\_index\_module](/nginx-docs/he-xin-gong-neng/http/ngx_http_index_module.md) 之前处理。

该模块默认不会被构建到 nginx 中，需要在编译时加入 `--with-http_random_index_module` 配置参数启用。

## 配置示例

```
location / {
    random_index on;
}
```

### random\_index

| -       | 说明                               |
| ------- | -------------------------------- |
| **语法**  | **random\_index** `on` \| `off`; |
| **默认**  | random\_index off;               |
| **上下文** | location                         |

启用或禁用 `location` 周边的模块处理。

## 原文档

* <http://nginx.org/en/docs/http/ngx_http_random_index_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_random_index_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.
