Skip to content

Instantly share code, notes, and snippets.

@vickonrails
Last active February 5, 2018 08:39
Show Gist options
  • Save vickonrails/02229737ea19f0f6bf1d4b63fc0874a8 to your computer and use it in GitHub Desktop.
Save vickonrails/02229737ea19f0f6bf1d4b63fc0874a8 to your computer and use it in GitHub Desktop.
//server.js
const express = require('express'),
https = require('https'),
http = require('http'),
fs = require('fs'),
app = express();
//credentials obtained from a Certificate Authority
var options = {
key: fs.readFileSync('/path/to/key.pem'),
cert: fs.readFileSync('/path/to/cert.pem')
};
//Binding the app on different ports so the app can be assessed bt HTTP and HTTPS
http.createServer(app).listen(80);
https.createServer(options, app).listen(443);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment