Spring Boot 2 - AJP

后端 未结 2 989
无人及你
无人及你 2021-02-10 23:39

I added an connector for AJP to my spring boot 2 project

 @Bean
 public ServletWebServerFactory servletContainer() {
        TomcatServletWebServerFactory tomcat         


        
2条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-11 00:31

    This works for me:

        @Bean
        public WebServerFactoryCustomizer servletContainer() {
          return server -> {
            if (server instanceof TomcatServletWebServerFactory) {
                ((TomcatServletWebServerFactory) server).addAdditionalTomcatConnectors(redirectConnector());
            }
          };
        }
    
        private Connector redirectConnector() {
           Connector connector = new Connector("AJP/1.3");
           connector.setScheme("http");
           connector.setPort(ajpPort);
           connector.setSecure(false);
           connector.setAllowTrace(false);
           return connector;
        }
    

提交回复
热议问题