Hi!

I have some problems with spring boot application and actuator. I decided to use IP addresses for boot-services and SBA. (for me it's good point and so comfortable). Main task is giving endpoints IP:port.

So, my yml properties here:

spring:
  boot:
    admin:
      client:
        url: http://spring-admin:8080/
        auto-deregistration: true
        instance:
          preferIp: true

management:
  port: 8080
  endpoint:
    health:
      show-details: ALWAYS
      probes:
        enabled: true
  server:
    port: 8080
  endpoints:
    web:
      exposure:
        include: "*"

I used the base starter: implementation("org.springframework.boot:spring-boot-starter-actuator")

Base endpoints for SBA have IP:port and it's ok.

But actuator endpoints don't have port. request: curl http://0.0.0.1:8080/actuator response:

{"_links":{"self":{"href":"http://0.0.0.1/actuator","templated":false},"beans":{"href":"http://0.0.0.1/actuator/beans","templated":false},"caches-cache":{"href":"http://0.0.0.1/actuator/caches/{cache}","templated":true},"caches":{"href":"http://0.0.0.1/actuator/caches","templated":false},"health":{"href":"http://0.0.0.1/actuator/health","templated":false},"health-path":{"href":"http://0.0.0.1/actuator/health/{*path}","templated":true},
"info":{"href":"http://0.0.0.1/actuator/info","templated":false},
…

It works if I use different port - 8081 and etc, but I must use only 8080.

Versions: spring boot: 2.3.3 build: Gradle KTS dependency-manager: 1.0.10 Kotlin version: 1.4.0 Java project version: 11 Spring cloud version: Hoxton.SR8

How I can solve this case? How I can set 8080 port for actuator endpoints? I would appreciate your immediate attention to this matter. Have a nice day!

Comment From: wilkinsona

The preferIp property is provided by Spring Boot Admin which is a separately managed, third-party project. I'm not sure what the property does or how it has been implemented, but I think this should be raised with the Spring Boot Admin team. If it turns out that a change in Spring Boot is required, we can re-open this issue and take another look.

Comment From: DrSequence

@wilkinsona Thanks!

Comment From: joshiste

@wilkinsona I agree that the prefer-ip property belongs to the SBA project. We don't influence the actuator endpoint and how it renders the links.

So imho doing a curl http://0.0.0.1:8080/actuator should return a response having the actuator links pointing to http://0.0.0.1:8080/actuator and not to http://0.0.0.1/actuator

Comment From: wilkinsona

In a vanilla Spring Boot application that's exactly what happens:

$ curl 10.0.0.20:8080/actuator 
{"_links":{"self":{"href":"http://10.0.0.20:8080/actuator","templated":false},"health":{"href":"http://10.0.0.20:8080/actuator/health","templated":false},"health-path":{"href":"http://10.0.0.20:8080/actuator/health/{*path}","templated":true},"info":{"href":"http://10.0.0.20:8080/actuator/info","templated":false}}}

The links are derived from the request URL returned from HttpServletRequest.getURL() (MVC) or ServerWebExchange.getRequest().getURI() (WebFlux). If the port is absent from these URLs something must be wrapping the request or manipulating its URL via a X-Forwarded-* header or the like.

I still don't see the connection with preferIp:true. @IliaEre, why do you believe it is significant to the problem you're seeing?

Comment From: joshiste

@IliaEre could you remove the SBA Client and see if the problem still occurs?