Skip to content

Instantly share code, notes, and snippets.

@astur astur/nodeserver.js
Created May 19, 2015

Embed
What would you like to do?
Node http/https server
var fs = require('fs');
var express = require('express');
var https = require('https');
var http = require('http');
var app = express();
var options = {
//openssl genrsa 1024 > key.pem
key: fs.readFileSync('./key.pem'),
//openssl req -x509 -new -key key.pem > cert.pem
cert: fs.readFileSync('./cert.pem')
};
app.get('/', function(req, res){
res.send('Hello World!');
});
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
You can’t perform that action at this time.