Created
June 4, 2019 08:13
-
-
Save abcprintf/037dfd3630d4fcf5aab094c0d070adcf to your computer and use it in GitHub Desktop.
Listening on HTTP and HTTPS
This file contains 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
// Host runing https: | |
var port = 3000; | |
var express = require('express'); | |
var fs = require("fs"); | |
var cert = { | |
key: fs.readFileSync('./cert/x.key'), | |
cert: fs.readFileSync('./cert/x.cer') | |
}; | |
var app = express() | |
, http = require('http').createServer(app) | |
, https = require('https').createServer(cert, app) | |
, io = require('socket.io').listen(https, { log: false }); | |
http.listen(3001, function() { | |
console.log('listening on *:' + 3001); | |
}); | |
// runing https port : 3000 | |
https.listen(port, function() { | |
console.log('listening on *:' + port); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment