actuator的端口暴露

这是我项目中的配置文件:

#服务监控与管理配置,运维相关
management:
    endpoints:
        web:
            exposure:
                include: refresh,health,info,env

补充一下这方面的知识:

1.访问路径:http://127.0.0.1:8080/actuator/health  访问项目监控需要加前缀 /actuator

2.配置端点

暴露部分端点

management.endpoints.web.exposure.include=info,health,beans,env

暴露所有端点

management.endpoints.web.exposure.include=*

不暴露beans端点

management.endpoints.web.exposure.exclude=beans

在上述配置中,首先使用 management.endpoints.web.exposure.include 暴露所有的端点,接着使用management.endpoints .web.exposure.exclud 排除 en 端点,这样就能够暴露除 env 外的所有 ctuator

3.扩展

 参考链接

https://www.ucloud.cn/yun/71225.html

https://blog.csdn.net/yaomingyang/article/details/84035975

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Spring Boot Actuator 提供了一些端点,可以让你监控和管理 Spring Boot 应用程序。其中包括一些敏感信息,例如应用程序的健康状况、配置信息、日志等等。为了保护这些敏感信息,你可以配置 Actuator 端点的访问密码。 以下是配置 Actuator 端点访问密码的步骤: 1. 在 application.properties 或 application.yml 文件中添加以下配置: ``` management.endpoints.web.exposure.include=* management.endpoint.health.show-details=always management.endpoint.info.enabled=true management.endpoint.logfile.enabled=true spring.security.user.name=admin spring.security.user.password=your_password ``` 上述配置中,`management.endpoints.web.exposure.include=*` 表示暴露所有 Actuator 端点,`management.endpoint.health.show-details=always` 表示展示详细的健康状况信息,`management.endpoint.info.enabled=true` 表示开启 info 端点,`management.endpoint.logfile.enabled=true` 表示开启 logfile 端点。 2. 在需要保护的端点上添加 `@Secured` 注解,如: ```java @RestController public class MyController { @GetMapping("/my-endpoint") @Secured("ROLE_ACTUATOR") public String myEndpoint() { // ... } } ``` 这里的 `@Secured("ROLE_ACTUATOR")` 表示只有具有 `ROLE_ACTUATOR` 权限的用户才能访问该端点。 3. 启动应用程序,并使用 `http://username:password@localhost:port/actuator/` 访问 Actuator 端点。其中,`username` 和 `password` 分别是你在第一步中配置的用户名和密码,`port` 是应用程序的端口号。 这样,你就可以保护 Actuator 端点的访问了。注意,在生产环境中,应该使用更加安全的身份验证方式,例如 OAuth2 或 JWT。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值