【发布时间】:2022-10-07 22:35:38
【问题描述】:
我为我的spring-boot 应用程序创建了一个docker 容器,并启用了actuator 端点。假设容器在端口 8080 上运行,它可以通过localhost:8080/actuator 访问,它公开端点如下:
{
"_links": {
"self": {
"href": "http://localhost:8080/actuator",
"templated": false
},
"health": {
"href": "http://localhost:8080/actuator/health",
"templated": false
},
...
}
问题:我在 apache2 代理后面,它重定向如下:
ProxyPass https://myserver.com/api http://localhost:8080
ProxyPassReverse https://myserver.com/api http://localhost:8080
现在如果我转到https://myserver.com/api/actuator,我可以看到端点,但这里缺少重写的上下文路径:http://myserver/actuator/health
问题:如何强制 Spring 使用额外的上下文路径 /api 构建管理端点路径?
我想要的执行器端点输出是:
http://myserver/api/actuator/health
{
"_links": {
"self": {
"href": "http://myserver/api/actuator",
"templated": false
},
"health": {
"href": "http://myserver/api/actuator/health",
"templated": false
},
... should be applied to all endpoints
}
那可能吗?
【问题讨论】:
标签: spring spring-boot spring-actuator