简体   繁体   中英

Spring Boot replicate embedded servlet customizer to management port

I have a custom WebServerFactoryCustomizer but its not available for management port. What's the best way to make the customization available to server on management port? The regular server is on port =8080 and management server is on port = 8082.

I tried playing around with ServletManagementWebServerFactoryCustomizer but it didn't work. Any pointers will be appreciated.

here is the customizer (to disable TRACE for Undertow)

public class UndertowCustomizer implements
  WebServerFactoryCustomizer<ConfigurableUndertowWebServerFactory> {

@Override
public void customize(final ConfigurableUndertowWebServerFactory undertowWebServerFactory) {
  undertowWebServerFactory.addDeploymentInfoCustomizers(deploymentInfo ->
      deploymentInfo.addInitialHandlerChainWrapper(handler ->
          new DisallowedMethodsHandler(handler, HttpString.tryFromString(HttpMethod.TRACE.name())))
  );
 }
}

A sample reproducible service is at https://github.com/ranarula/WebServerCustomizer

Indeed I feel lack of information regarding this topic as well but I was able to get it working by following the documentation Adding custom endpoints

what you can do is just put the customizer in spring.factories

org.springframework.boot.actuate.autoconfigure.web.ManagementContextConfiguration=UndertowCustomizer

javadocs of this class might be helpful as well ManagementContextConfiguration

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