Skip to content

Instantly share code, notes, and snippets.

@abcprintf
Created June 4, 2019 08:13
Show Gist options
  • Save abcprintf/037dfd3630d4fcf5aab094c0d070adcf to your computer and use it in GitHub Desktop.
Save abcprintf/037dfd3630d4fcf5aab094c0d070adcf to your computer and use it in GitHub Desktop.
Listening on HTTP and HTTPS
// 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