简体   繁体   中英

Spring Boot Actuator endpoints with set server.context-path

In spring boot app I set eg server.context-path=/mymodule . This is convenient because I don't need to repeat over and over again /mymodule prefix in @RequestMapping . Further I want to have actuator endpoints grouped together on URLs with common prefix so I set management.context-path=/actuator . Now actuator endpoint are mapped to /mymodule/actuator .

From security perspective I want to have actuator endpoints mapped to /actuator . Simple config on reverse proxy https://mydomain/api/mymodule -> http://oneofmyserver:port/mymodule protects that end users would not be able to access actuator.

Is it possible to map actuator endpoints to /actuator ?

Probably better solution from security perspective is to export actuator on totally different port. To do it just add such properties:

management.port=9080

You can also just change context-path of actuator endpoints by using

management.context-path=/actuator

You can use the management.endpoints.web.base-path property to change the prefix for your management endpoint. Reference from spring-boot document .

The following example remaps /actuator/health to /healthcheck ;

management.endpoints.web.base-path=/
management.endpoints.web.path-mapping.health=healthcheck

In case of you aren't able to use different ports and you have, for example, eureka in you environment, you can use the following:

  1. Configure additional metadata, that you send to eureka. Simply by adding there some parameter with value of your context-path. spring docs

  2. Configure Prometheus for using Eureka . After that you will get an access to your custom meta-data

  3. Finally you can use these new parameters in a relabeling step .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM