There is support for only one port to access actuator endpoints with the help of this:
management.server.port=
Comment From: wilkinsona
As with the main server, if you want to configure a second connector you must do so programatically. To have it apply to the separate management context that the actuator uses when running on a separate port, you must use @ManagementContextConfiguration
and register the class in spring.factories
rather than having it picked up by classpath scanning. Assuming that you are using Tomcat, your configuration class would look something like this:
@ManagementContextConfiguration(ManagementContextType.CHILD)
class SecondActuatorPortConfiguration {
@Bean
WebServerFactoryCustomizer<TomcatServletWebServerFactory> tomcatCustomizer() {
return (tomcat) -> {
tomcat.addAdditionalTomcatConnectors(createStandardConnector());
};
}
private Connector createStandardConnector() {
Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
connector.setPort(8082);
return connector;
}
}
And your spring.factories
file like this:
org.springframework.boot.actuate.autoconfigure.web.ManagementContextConfiguration=example.SecondActuatorPortConfiguration
If you have any further questions, please follow up on Stack Overflow or Gitter. As mentioned in the guidelines for contributing, we prefer to use GitHub issues only for bugs and enhancements.
Comment From: dineshv1234567
Thank you @wilkinsona . I am using Undertow. Can you please provide createStandardConnector() for that.
Comment From: wilkinsona
You'd need to use an UndertowBuilderCustomizer
bean to add an HTTP listener. If you need some help with that then, as I said above, please follow up on Stack Overflow or Gitter.
Comment From: dineshv1234567
@wilkinsona I have posted about this on Stack overflow https://stackoverflow.com/q/62941729/13944037