Skip to content

Instantly share code, notes, and snippets.

@Overdrivr
Last active November 8, 2016 13:56
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 Overdrivr/263c6c7730b12c74637109d7beaae711 to your computer and use it in GitHub Desktop.
Save Overdrivr/263c6c7730b12c74637109d7beaae711 to your computer and use it in GitHub Desktop.
HTTPS static file server with connect
var connect = require('connect');
var serveStatic = require('serve-static');
var https = require('https');
// Get certificates for free here
// https://letsencrypt.org/
var key = fs.readFileSync('./key.pem');
var cert = fs.readFileSync('./cert.pem')
var options = {
key: key,
cert: cert
};
var port = 443;
var folder = __dirname;
var app = connect();
app.use(serveStatic(folder));
https.createServer(options, app).listen(port);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment