title: Forwarding http to https in node.js express app using EBS & ELB environment
body: <p>I am using the following to redirect all http requests to https requests.</p>
  
  <p>I can see from logs that the header 'x-forwarded-proto' is never populated and is undefined.</p>
  
  <pre><code>app.get('*', function(req, res, next) {
      //http://docs.aws.amazon.com/ElasticLoadBalancing/latest/DeveloperGuide/TerminologyandKeyConcepts.html#x-forwarded-proto
      if (req.headers['x-forwarded-proto'] != "https") {
          res.redirect('https://' + req.get('host') + req.url);
      } else {
          next();     
      }
  });
  </code></pre>
  
  <p>It is causing a redirect loop. How can I redirect properly without looping? </p>