This is a conitnuation of #1667 and #1771 and also possibly #2320.
The very same issue is still present in SBA:
while management.port
property is set to a custom port - this custom port is not used to access endpoints returned by Spring Boot application's /actuator
endpoint.
No better thing then to quote # 1771:
On my application "details" page I can see that port.management is set to 9999. I can also see that the Pod's IP is correct and the port next to it is correct as well. The call to the health endpoint is made using 9999. Every other call is made using port 80.
I can see that links in responses from /actuator do not contain the port name, they look like http://my-app/actuator/env, and I suspect this is the endpoint that is used (including the implicit port 80), and management.port is not used.
Is there a way I can force boot-admin to always make all the requests on the right port?
Although @ulischulte closed the previous issues, I beg to disagree that this isn't an issue on Spring Boot Admin part.
It would seem that the current solution is to implement a custom configuration class in the Spring Boot Application itself to correct the links returned by the /actuator
endpoint.
However, SBA's own documentation lists management.port
property described as
The port is substituted in the service URL and will be used for accessing the actuator endpoints.
this is not what happens in reality and in my opinion the necessity to configure each individual spring boot application impairs the SBA service discovery mechanism greatly.
Can you please consider making management.port
property imperative and make sure the port number is indeed appended to all of the /actuator/...
endpoints?
Thank you!
Comment From: wilkinsona
As far as I can tell, this isn't a Spring Boot problem. I tried to reproduce the behaviour you've described using 2.5.6 and the following configuration properties:
management.server.port:8081
management.endpoints.web.exposure.include=*
All links returned from /actuator
use port 8081:
$ http :8081/actuator
HTTP/1.1 200
Connection: keep-alive
Content-Type: application/vnd.spring-boot.actuator.v3+json
Date: Thu, 21 Oct 2021 17:17:36 GMT
Keep-Alive: timeout=60
Transfer-Encoding: chunked
{
"_links": {
"beans": {
"href": "http://localhost:8081/actuator/beans",
"templated": false
},
"caches": {
"href": "http://localhost:8081/actuator/caches",
"templated": false
},
"caches-cache": {
"href": "http://localhost:8081/actuator/caches/{cache}",
"templated": true
},
"conditions": {
"href": "http://localhost:8081/actuator/conditions",
"templated": false
},
"configprops": {
"href": "http://localhost:8081/actuator/configprops",
"templated": false
},
"configprops-prefix": {
"href": "http://localhost:8081/actuator/configprops/{prefix}",
"templated": true
},
"env": {
"href": "http://localhost:8081/actuator/env",
"templated": false
},
"env-toMatch": {
"href": "http://localhost:8081/actuator/env/{toMatch}",
"templated": true
},
"health": {
"href": "http://localhost:8081/actuator/health",
"templated": false
},
"health-path": {
"href": "http://localhost:8081/actuator/health/{*path}",
"templated": true
},
"heapdump": {
"href": "http://localhost:8081/actuator/heapdump",
"templated": false
},
"info": {
"href": "http://localhost:8081/actuator/info",
"templated": false
},
"loggers": {
"href": "http://localhost:8081/actuator/loggers",
"templated": false
},
"loggers-name": {
"href": "http://localhost:8081/actuator/loggers/{name}",
"templated": true
},
"mappings": {
"href": "http://localhost:8081/actuator/mappings",
"templated": false
},
"metrics": {
"href": "http://localhost:8081/actuator/metrics",
"templated": false
},
"metrics-requiredMetricName": {
"href": "http://localhost:8081/actuator/metrics/{requiredMetricName}",
"templated": true
},
"scheduledtasks": {
"href": "http://localhost:8081/actuator/scheduledtasks",
"templated": false
},
"self": {
"href": "http://localhost:8081/actuator",
"templated": false
},
"threaddump": {
"href": "http://localhost:8081/actuator/threaddump",
"templated": false
}
}
}
Perhaps you're sending a request with an X-Forwarded-…
header as discussed in https://github.com/spring-projects/spring-boot/issues/24796?
Comment From: odu14ick
@wilkinsona thanks for that piece of information, indeed I didn't check the issue you've posted here before. Will check tomorrow and get back to this issue.
Comment From: odu14ick
@wilkinsona Can confirm, you're exactly right, the issue I was having is the very same mentioned in #2479
Istio proxying requests + Envoy not setting the x-forwarded-port
header.
Indeed this is worked around by setting the server.forward-headers-strategy: none
property in the Spring Boot Application itself (not anything that can be fix on Spring Boot Admin side).
Huge thanks for the link and the explanations you've provided there, somehow I overlooked that issue before.