Skip to content

Instantly share code, notes, and snippets.

@jbueza
Last active April 15, 2016 16:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbueza/99ae27ea21eca7b4f6e51fefbaa89266 to your computer and use it in GitHub Desktop.
Save jbueza/99ae27ea21eca7b4f6e51fefbaa89266 to your computer and use it in GitHub Desktop.
NodeJS, Express, Elastic Beanstalk, Elastic Load Balancer (Redirect HTTP to HTTPS)
app.use(function(req, res, next) {
if ((!req.secure) && (req.get('X-Forwarded-Proto') !== 'https')) {
res.redirect('https://' + req.get('Host') + req.url);
} else {
next();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment