Skip to content

Instantly share code, notes, and snippets.

@herpiko
Last active September 8, 2017 09:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save herpiko/49329b0f57ea380e1b84407112095e04 to your computer and use it in GitHub Desktop.
Save herpiko/49329b0f57ea380e1b84407112095e04 to your computer and use it in GitHub Desktop.
HTTPS Express
var fs = require('fs');
var http = require('http');
var https = require('https');
var privateKey = fs.readFileSync('/tmp/key.pem', 'utf8');
var certificate = fs.readFileSync('/tmp/cert.pem', 'utf8');
var credentials = {key: privateKey, cert: certificate, passphrase : '123456'};
var express = require('express');
var app = express();
// your express configuration here
var httpServer = http.createServer(app);
var httpsServer = https.createServer(credentials, app);
httpServer.listen(8080);
httpsServer.listen(8443);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment