Created
September 5, 2013 18:09
-
-
Save cerebrl/6453872 to your computer and use it in GitHub Desktop.
How to enable https in Node/Express. From http://stackoverflow.com/questions/5998694/how-to-create-an-https-server-in-express-js-node-js
This file contains 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 express = require('express'); | |
var https = require('https'); | |
var http = require('http'); | |
var fs = require('fs'); | |
// This line is from the Node.js HTTPS documentation. | |
var options = { | |
key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'), | |
cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem') | |
}; | |
// Create a service (the app object is just a callback). | |
var app = express(); | |
// Create an HTTP service. | |
http.createServer(app).listen(80); | |
// Create an HTTPS service identical to the HTTP service. | |
https.createServer(options, app).listen(443); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment