title: Spring Boot & ELB - How do I make the load balancer redirect http to https?
body: <p>I have deployed a Spring Boot application via Elastic Beanstalk. I'm using a load balancer, so this is the flow (as far as I understand):  </p>
  
  <p>Internet/Browser request ---HTTPS---> Load Balancer ---HTTP---> Spring Boot App Server  </p>
  
  <p>So essentially, the SSL terminates at the load balancer and the app server just deals with plain old HTTP.  </p>
  
  <p>But in the case of a HTTP request from the browser, I would like the load balancer to automatically redirect to HTTPS.  </p>
  
  <p>There are several questions about this issue:</p>
  
  <p><a href="https://stackoverflow.com/questions/30229352/spring-boot-with-embedded-tomcat-behind-aws-elb-https-redirect">Spring Boot with Embedded Tomcat behind AWS ELB - HTTPS redirect</a><br>
  <a href="https://stackoverflow.com/questions/22625699/how-to-redirect-automatically-to-https-with-spring-boot?rq=1">How to redirect automatically to https with Spring Boot</a><br>
  <a href="https://stackoverflow.com/questions/26655875/spring-boot-redirect-http-to-https?noredirect=1&amp;lq=1">Spring Boot redirect HTTP to HTTPS</a>  </p>
  
  <p>But none of the answers to these questions make sense to me. Perhaps I'm misunderstanding, but all the answers basically make the Spring Boot app only server HTTPS request (for example when using <code>http.requiresChannel().anyRequest().requiresSecure()</code>).    </p>
  
  <p>However, this goes against the flow because I'm perfectly fine with the SSL terminating at the load balancer and the Spring Boot app server just dealing with HTTP. So if I require SSL at the spring boot level, then I'll need to do an end-to-end SSL connection, which isn't really required for my application.  </p>
  
  <p>I have also used the following properties, which don't seem to help either:  </p>
  
  <pre><code>server.tomcat.remote-ip-header=x-forwarded-for
  server.tomcat.protocol-header=x-forwarded-proto  
  </code></pre>