# ngx\_stream\_access\_module

* [示例配置](#example_configuration)
* [指令](#directives)
  * [allow](#allow)
  * [deny](#deny)

`ngx_stream_access_module` 模块（1.9.2）允许对某些客户端地址限制访问。

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

```
server {
    ...
    deny  192.168.1.1;
    allow 192.168.1.0/24;
    allow 10.1.1.0/16;
    allow 2001:0db8::/32;
    deny  all;
}
```

按顺序检查规则，直到找到第一个匹配项。在此示例中，仅允许 IPv4 网络 `10.1.1.0/16` 和 `192.168.1.0/24`（不包括地址 `192.168.1.1`）和 IPv6 网络`2001:0db8::/32` 进行访问。

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

### allow

|       - | 说明                                                 |
| ------: | -------------------------------------------------- |
|  **语法** | **allow** `address` \| `CIDR` \| `unix:` \| `all`; |
|  **默认** | ——                                                 |
| **上下文** | stream、server                                      |

允许指定的网络或地址访问。如果指定了值 `unix:`，则允许访问所有 UNIX 域套接字。

### deny

|       - | 说明                                                |
| ------: | ------------------------------------------------- |
|  **语法** | **deny** `address` \| `CIDR` \| `unix:` \| `all`; |
|  **默认** | ——                                                |
| **上下文** | stream、server                                     |

拒绝指定的网络或地址访问。如果指定了值 `unix:`，则拒绝所有 UNIX 域套接字的访问。

## 原文档

<http://nginx.org/en/docs/stream/ngx_stream_access_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/stream/ngx_stream_access_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.
