Skip to content

Instantly share code, notes, and snippets.

@avimar
Created February 1, 2016 06:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save avimar/58f0143aff0c562fe355 to your computer and use it in GitHub Desktop.
Save avimar/58f0143aff0c562fe355 to your computer and use it in GitHub Desktop.
var myURL="mydomain.com";
var restifyOptions={}
restifyOptions.certificate = fs.readFileSync('PathTo:fullchain.pem');
restifyOptions.key = fs.readFileSync('PathTo:privkey.pem');
var server = restify.createServer(restifyOptions);
var nonSecure = restify.createServer({name: 'redirectToSSL'});
nonSecure.get(/.*/,function (req, res, next) {
res.redirect(301, 'https://' + myURL + req._url.href, next);
});
nonSecure.listen(Common.conf.get('portRedirect'), function() {
logger.info('%s listening at %s', nonSecure.name, nonSecure.url);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment