Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Boot Actuator port when deployed to external Tomcat container

I have a Spring Boot application that is deployed to an external Tomcat container (not using the embedded container), and am trying to get the actuator set up. The problem is that the management.port in application.properties does not seem to be honored by Tomcat. When I run Spring Boot with embedded Tomcat it works just fine.

For example, having the following set in application.properties:

management.port=9010

Working endpoints for embedded container

  • http://localhost:9010/health

Non-working endpoints for external container running on port 8080

  • http://localhost:9010/health
  • http://localhost:8080/health
  • http://localhost:9010/<appName>/health
  • http://localhost:8080/<appName>/health

Is there a special configuration I need in the Tomcat container to expose a Spring Boot actuator end point?

I've tried setting an environment variable of MANAGEMENT_PORT. Most (almost all) of the documentation available is using the embedded Tomcat, so tracking down this issue has proved to be challenging.

The third comment on this answer provided some possible insight: https://stackoverflow.com/a/28689853/2601060, which points to a GitHub file indicating that if the management port is not set, it will be the same as the server port.

like image 323
mnd Avatar asked Apr 21 '15 14:04

mnd


3 Answers

We cannot specify an additional port with an external Tomcat container. Here is why : https://github.com/spring-projects/spring-boot/issues/552

The only way is to extend the endpoints using a context path, say "/management" and apply security on it.

like image 171
DecipherX Avatar answered Sep 17 '22 03:09

DecipherX


Yes, if your application.properties is having property called "management.port: 9001" and "server.port: 9000". Then your application end-points will deploy on port 9000 and actuator end-points will deployed on port 9001.

So its up to us. We can mention both properties with same port, application will works correctly.

like image 45
Eswar Goud Avatar answered Sep 17 '22 03:09

Eswar Goud


I had same issue in my local environement ,

  • I fixed it by changing the tomcat , (reinstalling a new one ),
  • also by changing the default port in > \apache-tomcat-9.0.52\conf\serve.xml to 8082 -and then you can access to yout actuator link : localhost:8082/yourwarName/actuator/health

:) hope it helps someone one day..

like image 32
tomatoNG Avatar answered Sep 19 '22 03:09

tomatoNG