> For the complete documentation index, see [llms.txt](https://docs.console.zenlayer.com/welcome/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.console.zenlayer.com/welcome/cn/elastic-compute/load-balancing/create-a-listener.md).

# 创建监听器

负载均衡器必须配置监听器和后端服务器后才能正常运行。

创建负载均衡器后，您可以通过以下任一方式添加监听器：

* 前往 **Elastic Compute** > **Load Balancer** > **Listener** > **Create Listener**。
* 选择目标负载均衡器，选择 **Actions** > **Add Listener**。

监听器定义了负载均衡器接收传入流量并将其转发至后端服务器的方式。它指定协议、监听端口、转发行为、调度算法、后端服务器配置以及健康检查设置。通过创建监听器，您可以控制不同类型的流量如何分发到后端服务器。

## 前提条件

创建监听器前，请确保：

* 已创建负载均衡器实例。
* 后端服务器（实例或 IP 地址）已在同一全局 VPC 中可用。
* 负载均衡器关联的安全组已放行所需端口。

## 操作步骤

前往 **Elastic Compute** > **Load Balancer** > **Listener** > **Create Listener**。

{% stepper %}
{% step %}
**选择负载均衡器**

选择要添加监听器的现有负载均衡器。负载均衡器的名称和 ID 将显示以供识别。

如果没有合适的负载均衡器，请点击 **New Load Balancer** 进行创建。
{% endstep %}

{% step %}
**配置转发规则**

转发规则定义了监听器如何处理传入流量并将其转发至后端服务器。它决定：

* 流量入口条件（协议和监听端口）
* 转发模式（如目标 NAT）
* 用于分发请求的调度算法

有关如何配置协议、监听端口、转发模式和调度算法的详细信息，请参见[**编辑监听器**](/welcome/cn/elastic-compute/load-balancing/edit-listener.md)。
{% endstep %}

{% step %}
**配置后端服务器**

后端服务器接收监听器转发的流量。您可以通过以下任一方式配置后端服务器：

* **按实例**：直接从现有弹性计算实例中选择后端服务器。
* **按 IP 地址**：手动指定后端服务器的 IP 地址。

有关如何配置私有 IPv4、端口和权重的详细信息，请参见[**添加后端服务器**](/welcome/cn/elastic-compute/load-balancing/add-backend-servers-to-a-listener.md)。
{% endstep %}

{% step %}
**配置健康检查**

健康检查监控后端服务器的可用性，确保流量仅路由到健康的服务器。

* 启用**配置健康检查**以激活健康监控。
* 负载均衡器会自动将不健康的服务器从流量分发中移除，并在其恢复后重新加入。

您可以配置 **Fail-Open**，并从 **TCP**/**HTTP**/**PING** 中选择健康检查协议。

详情请参见[**修改健康检查**](/welcome/cn/elastic-compute/load-balancing/modify-health-check.md)。
{% endstep %}

{% step %}
**为监听器命名**

为监听器提供一个名称以便识别其用途。请使用清晰且具描述性的名称，例如 `Listener-TCP-01`。

名称长度为 2 至 63 个字符，可包含字母、数字、连字符（-）、下划线（\_）、斜杠（/）和句点（.），且必须以字母或数字开头和结尾。
{% endstep %}
{% endstepper %}

## 结果

监听器创建完成后，您可以在监听器列表页查看它。

点击监听器名称进入详情页，可查看后端服务器列表、转发规则、健康检查配置及基本信息。

监听器创建并添加到负载均衡器后：

* 负载均衡器开始在指定协议和端口上接受流量。
* 流量根据所选调度算法分发到后端服务器。
* 健康检查持续监控后端服务器的可用性。

您可以在同一台负载均衡器上创建多个监听器，以处理不同的协议、端口或流量类型。

***

## 删除监听器

如果您不再需要某个监听器，可以手动将其删除。

在监听器列表页，前往 **Actions** > **Delete**。

{% hint style="info" %} <mark style="color:blue;">**注意**</mark>

<mark style="color:blue;">删除监听器将立即解除所有关联的后端服务器，请谨慎操作。</mark>
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.console.zenlayer.com/welcome/cn/elastic-compute/load-balancing/create-a-listener.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
