title: Redirect Elastic Beanstalk HTTP requests to HTTPS with nginx
body: <p>I want a redirect from HTTP request to HTTPS on Elastic Beanstalk with nginx as proxy system.</p>
  
  <p>I've found a lot of advices on Google but no one helped, it doesn't redirect. </p>
  
  <p>That is my current <code>test.config</code> file in <code>.ebexentions</code> directory:</p>
  
  <pre><code>files:
  "/etc/nginx/conf.d/proxy.conf" :
      mode: "000644"
      owner: root
      group: root
      content: |
          server{
              if ($http_x_forwarded_proto = "http") {
                  return 301 https://$host$request_uri;
              }
          }
  </code></pre>
  
  <p>I've also tried countless other settings, none of them worked.</p>
  
  <p>That are my load balancer settings:
  <a href="https://i.stack.imgur.com/rw8g8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rw8g8.png" alt="enter image description here"></a></p>
  
  <p>I hope you can help me. :)</p>