Created
February 1, 2016 06:10
-
-
Save avimar/58f0143aff0c562fe355 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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