title: Redirect Http to Https in Elastic BeansTalk, Tomcat, Nginx
body: <p>I have a spring boot application (1.5.3) which is running on a Tomcat container with Nginx as the load balancer.
  I have created below file:</p>
  
  <pre><code>.ebextentions/nginx/conf.d/myapp.conf
  </code></pre>
  
  <p>And I added the below content based on this <a href="https://aws.amazon.com/premiumsupport/knowledge-center/redirect-http-https-elb/" rel="nofollow noreferrer">article</a>: </p>
  
  <pre><code>server {
    if ($http_x_forwarded_proto != 'https') {
      rewrite ^(.*) https://$host$1 redirect;
    }
  }
  </code></pre>
  
  <p>I have installed SSL certificate in certificate manager and set it in my environment. Now the application serves both HTTP and https request. I want to redirect all HTTP requests to https without falling into a redirect loop. but doesn't work. </p>