26

Is there an easy way to add a prefix to all the Actuator endpoints?

/env ->     /secure/env
/health ->  /secure/health
/info ->    /secure/info
...
codependent
  • 23,193
  • 31
  • 166
  • 308

3 Answers3

32

Jesper's answer is completely right, but I was looking for a more straightforward way of prefixing all endpoints, and it can be done with management.context-path, e.g.:

management:
  context-path: /secure

-> /secure/env
-> /secure/health
...
codependent
  • 23,193
  • 31
  • 166
  • 308
  • 11
    Changed in Spring Boot 2 to `management.endpoints.web.base-path` https://docs.spring.io/spring-boot/docs/2.1.x/reference/htmlsingle/#production-ready-customizing-management-server-context-path – Ivar Nov 15 '18 at 17:13
17

According to current Spring-Boot documentation, the property to change is:

management.endpoints.web.base-path=/secure
Darrin West
  • 298
  • 2
  • 11
14

Set the properties endpoints.{name}.path in your application.properties. For example:

endpoints.actuator.path=/secure/actuator
endpoints.env.path=/secure/env
endpoints.health.path=/secure/health
endpoints.info.path=/secure/info

To enable security on an endpoint, set endpoints.{name}.sensitive to true. For example:

endpoints.health.sensitive=true

See also Securing sensitive endpoints, Actuator Security and HTTP health endpoint access restrictions in the Spring Boot reference documentation if you want to secure the actuator endpoints of your application.

See Common application properties in the Spring Boot reference documentation for a list of common properties that you can set in application.properties.

Jesper
  • 202,709
  • 46
  • 318
  • 350
  • 1
    @Steffi things have changed in Spring Boot 2. See the documentation: [Actuator properties](https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#actuator-properties) – Jesper Oct 19 '19 at 13:20