【问题标题】:Spring boot actuator health check context pathSpring Boot 执行器健康检查上下文路径
【发布时间】:2017-10-16 21:16:33
【问题描述】:
我的 Spring 引导服务器上下文路径:/test
我使用 nginx 配置为“https://localhost:8443/test”基本路径设置了身份验证,此基本路径中的其余 api 是边缘服务。
问题:我不希望我的健康服务暴露为边缘服务并接受身份验证。但是执行器的健康检查是作为管理员服务提供的,并且管理员的上下文路径不会覆盖应用程序的基本路径。
我可以在我的应用程序中做任何调整来区分 rest api 和执行器的健康检查 api 之间的上下文路径。
Dropwizard 很容易做到这一点。
【问题讨论】:
标签:
java
rest
spring-boot
spring-boot-actuator
health-monitoring
【解决方案1】:
您可以使用 spring-security 来保护管理端点:
将spring-boot-starter-security 添加到您的依赖项中:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
这本身将保护所有端点。如果您只想保护 mgmt 的,请添加此属性:
security.basic.enabled=false
您还可以为此设置不同的用户/密码:
security.user.name=admin
security.user.password=new_password
感谢this post