> For the complete documentation index, see [llms.txt](https://potoyang.gitbook.io/spring-in-action-v5/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://potoyang.gitbook.io/spring-in-action-v5/di-16-zhang-shi-yong-springboot-actuator/16.1-jie-shao-actuator/16.1.2-qi-yong-he-jin-yong-actuator-duan-dian.md).

# 16.1.2 启用和禁用 Actuator 端点

您可能已经注意到，默认情况下只启用了 `/health` 和 `/info` 两个端点。由于大多数 Actuator 携带有敏感信息，所以应予以保护。Actuator 自身并没有提供安全措施，但您可以使用 Spring Security 来保护 Actuator。对于禁用的端点，您可以手动将其打开。

有两个配置属性： `management.endpoints.web.exposure.include` 和 `management.endpoints.web.exposure.exclude`， 可用于控制端点的启用和关闭。使用 `management.endpoints.web.exposure.include`，您可以指定要启用的端点。例如，如果您只想公开 `/health`、`/info`、`/beans` 和 `/conditions`，可以使用以下配置：

```yaml
management:
  endpoints:
    web:
      exposure:
        include: health,info,beans,conditions
```

`management.endpoints.web.exposure.include` 属性也可以使用星号（`*`）通配符，将所有 Actuator 端点都启用：

```yaml
management:
  endpoints:
    web:
      exposure:
        include: '*'
```

如果要启用除少数端点以外的所有端点，通常更方便的做法是：使用通配符将它们全部包含在内，然后显式排除一些。例如，启用所有但除了 `/threaddump` 和 `/heapdump` 之外的 Actuator 端点。您可以像下面这样设置 `management.endpoints.web.exposure.include` 和 `management.endpoints.web.exposure.exclude` 属性：

```yaml
management:
  endpoints:
    web:
      exposure:
        include: '*'
        exclude: threaddump,heapdump
```

如果您决定不仅仅启用 `/health` 和 `/info`，那么配置 Spring Security 以限制对其他端点的任意访问是个好主意。我们将在第 16.4 节讨论如何保护 Actuator 端点。现在，让我们看看如何访问这些已经启用的 HTTP 端点。
