title: Spring Boot with Embedded Undertow behind AWS ELB - HTTP to HTTPS redirect
body: <p>I'm running a Spring boot (Jhipster/Undertow) application on port 8080 on an AWS EC2 instance.</p>
  
  <p>I have an AWS ELB configured to redirect</p>
  
  <pre><code> 80 -&gt; 8080
   443 (SSL termination happens here) -&gt; 8080
  </code></pre>
  
  <p>The application uses Spring Security and if you user arrives to <a href="http://example.com" rel="nofollow noreferrer">http://example.com</a> I want it to redirect to <a href="https://example.com" rel="nofollow noreferrer">https://example.com</a>, to use SSL.</p>
  
  <p>I have found various examples of configuring this in <a href="https://stackoverflow.com/questions/30229352/spring-boot-with-embedded-tomcat-behind-aws-elb-https-redirect">Tomcat</a> but none using Undertow.</p>
  
  <p>I have tried this, with a second port 8089, and it does redirect as required, but this causes port 8080 to also redirects which I don't want.</p>
  
  <pre><code>80 -&gt; 8089
  443 (SSL termination happens here) -&gt; 8080
  </code></pre>
  
  <pre class="lang-java prettyprint-override"><code>@Bean
  public EmbeddedServletContainerFactory undertow() {
  
      UndertowEmbeddedServletContainerFactory undertow = new UndertowEmbeddedServletContainerFactory();
      undertow.addBuilderCustomizers(builder -&gt; builder.addHttpListener(8089, "0.0.0.0"));
      undertow.addDeploymentInfoCustomizers(deploymentInfo -&gt; {
          deploymentInfo.addSecurityConstraint(new SecurityConstraint()
                  .addWebResourceCollection(new WebResourceCollection()
                          .addUrlPattern("/*"))
                  .setTransportGuaranteeType(TransportGuaranteeType.CONFIDENTIAL)
                  .setEmptyRoleSemantic(SecurityInfo.EmptyRoleSemantic.PERMIT))
                  .setConfidentialPortManager(exchange -&gt; 443);
      });
      return undertow;
  }
  </code></pre>
  
  <p>How can I configure Undertow to achieve this?</p>