title: How to force https on elastic beanstalk?
body: <p>I can't seem to force https on the free usage tier of elastic beanstalk.</p>
  
  <p>I have tried the following suggestion at <a href="https://stackoverflow.com/questions/6858492/how-to-force-https-on-amazon-elastic-beanstalk-without-failing-the-health-check">How to force https on amazon elastic beanstalk without failing the health check</a></p>
  
  <p>Using this Apache rewrite rule</p>
  
  <pre><code>RewriteEngine On
  RewriteCond %{HTTP:X-Forwarded-Proto} !https
  RewriteCond %{REQUEST_URI} !^/status$ 
  RewriteCond %{REQUEST_URI} !^/version$ 
  RewriteCond %{REQUEST_URI} !^/_hostmanager/ 
  RewriteRule . https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
  </code></pre>
  
  <p>When I try that, http requests do not get redirected to https as I would like. Instead, the http page loads normally. I've also tried to use the X-Forwarded-Port header with the same result. </p>
  
  <p>I've also tried the following rewrite rule</p>
  
  <pre><code>RewriteCond %{SERVER_PORT} 80
  RewriteRule . https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
  </code></pre>
  
  <p>And this rule causes a redirect loop. So it would seem that the apache rewrite rules don't pick up the Elastic Load Balancer headers X-Forwarded-Port and  X-Forwarded-Proto, but also a redirect loop isn't what I am going for either.</p>
  
  <p>Please help. I am new to AWS, Elastic Beanstalk, and not very familiar with Apache rules. I am not too sure where to go from here. Thanks.</p>