Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Boot Actuator endpoints with set server.context-path

In spring boot app I set e.g. 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?

like image 634
Łukasz Idkowiak Avatar asked Aug 21 '15 09:08

Łukasz Idkowiak


People also ask

How do you change the context path of a Spring Boot application?

Just like many other configuration options, the context path in Spring Boot can be changed by setting a property, server. servlet. context-path. Note that this works for Spring Boot 2.

How do I change the path of my actuator?

By default base-path of actuator endpoints is /actuator , we can change it to any other value by setting management. endpoints. web. base-path in application properties file.

How do you expose actuator endpoints in Spring Boot?

To enable Spring Boot actuator endpoints to your Spring Boot application, we need to add the Spring Boot Starter actuator dependency in our build configuration file. Maven users can add the below dependency in your pom. xml file. Gradle users can add the below dependency in your build.

Can we have multiple context path in Spring Boot?

In order to have multiple context paths, you're limited to deploying the application multiple times with that convenient property set to what you want for each deployment. However, this is resource expensive because you're spinning up two applications for every one application you would normally spin up.


1 Answers

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
like image 159
Jakub Kubrynski Avatar answered Nov 13 '22 18:11

Jakub Kubrynski