title: Spring Boot 2 - AJP
body: <p>I added an connector for AJP to my spring boot 2 project</p>
  
  <pre><code> @Bean
   public ServletWebServerFactory servletContainer() {
          TomcatServletWebServerFactory tomcat = new 
     TomcatServletWebServerFactory() {
              @Override
              protected void postProcessContext(Context context) {
                  SecurityConstraint securityConstraint = new SecurityConstraint();
                  securityConstraint.setUserConstraint("CONFIDENTIAL");
                  SecurityCollection collection = new SecurityCollection();
                  collection.addPattern("/*");
                  securityConstraint.addCollection(collection);
                  context.addConstraint(securityConstraint);
              }
          };
          tomcat.addAdditionalTomcatConnectors(redirectConnector());
  
          return tomcat;
      }
  
      private Connector redirectConnector() {
          Connector connector = new Connector("AJP/1.3");
          connector.setScheme("http");
          connector.setPort(ajpPort);
          connector.setSecure(false);
          connector.setAllowTrace(false);
          return connector;
      }
  </code></pre>
  
  <p>This works fine. I can now access my spring boot application over my apache webserver. But now if i run my spring boot application i can not do access my spring boot application directly. So this url doesn't work anymore</p>
  
  <p><a href="http://localhost:13080/online/showlogin?m=test" rel="noreferrer">http://localhost:13080/online/showlogin?m=test</a></p>
  
  <p>If i disable the AJP Connector the URL works again. I have tried the following</p>
  
  <pre><code> private Connector redirectConnector2() {
      Connector connector = new Connector(TomcatServletWebServerFactory.DEFAULT_PROTOCOL);
      connector.setScheme("http");
      connector.setPort(13080);
      connector.setSecure(false);
      connector.setAllowTrace(false);
      return connector;
  }
  ...
  tomcat.addAdditionalTomcatConnectors(redirectConnector2());
  ...
  </code></pre>
  
  <p>But this does not help me.</p>