Created
August 28, 2014 18:22
-
-
Save seansullivan/836613655c3b593ea70e to your computer and use it in GitHub Desktop.
Lightweight Node.js HTTPS Server
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 https = require('https'); | |
var http = require('http'); | |
var fs = require('fs'); | |
var express = require('express'); | |
var options = { | |
key: fs.readFileSync('key.pem'), | |
cert: fs.readFileSync('cert.pem') | |
}; | |
// Create a service (the app object is just a callback). | |
var app = express(); | |
app.use(express.static('../')); | |
// Create an HTTPS service identical to the HTTP service. | |
https.createServer(options, app).listen(4443); | |
http.createServer(app).listen(8080); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment