I created a docker container of my spring-boot application with actuator endpoint enabled. Assuming the container runs on port 8080, it is accessible at localhost:8080/actuator, which exposes the endpoints as follows:
{
"_links": {
"self": {
"href": "http://localhost:8080/actuator",
"templated": false
},
"health": {
"href": "http://localhost:8080/actuator/health",
"templated": false
},
...
}
Problem: I'm behind an apache2 proxy, which redirects as follows:
ProxyPass https://myserver.com/api http://localhost:8080
ProxyPassReverse https://myserver.com/api http://localhost:8080
Now if I go to https://myserver.com/api/actuator, I can see the endpoints, but the rewritten context path is missing here: http://myserver/actuator/health
Question: how can I force Spring to build the management endpoint paths with an additional context-path /api?
My desired actuator endpoint output would be:
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
}
Is that possible?
Actually this is nothing that can be solved in spring directly, but with
X-Forwarded-Prefixin the proxy in front:apache2 config:
application.properties:
server.forward-headers-strategy=framework