使用set server.context-path的Spring Boot Actuator端点

Łuk*_*iak 3 spring spring-boot spring-cloud spring-boot-actuator

在春季启动应用程序我设置例如server.context-path=/mymodule.这很方便,因为我不需要一遍又一遍地重复/mymodule前缀@RequestMapping.此外,我希望将执行器端点组合在具有公共前缀的URL上,以便设置management.context-path=/actuator.现在执行器端点映射到/mymodule/actuator.

从安全角度来看,我希望将执行器端点映射到/actuator.反向代理上的简单配置https://mydomain/api/mymodule -> http://oneofmyserver:port/mymodule可保护最终用户无法访问执行器.

是否可以将执行器端点映射到/actuator

Jak*_*ski 6

从安全角度来看,可能更好的解决方案是在完全不同的端口上输出执行器.要做到这一点,只需添加以下属性:

management.port=9080
Run Code Online (Sandbox Code Playgroud)

您也可以通过使用更改执行器端点的上下文路径

management.context-path=/actuator
Run Code Online (Sandbox Code Playgroud)


fua*_*uat 5

您可以使用该management.endpoints.web.base-path属性来更改管理端点的前缀。来自 spring-boot 文档的参考

以下示例将/actuator/health重新映射到/healthcheck

management.endpoints.web.base-path=/
management.endpoints.web.path-mapping.health=healthcheck
Run Code Online (Sandbox Code Playgroud)