使用 https with express

首先,你必须使用 OpenSSL( 教程 ) 生成公钥和私钥。

var express = require("express");
var http =require ("http"); 
var https=require ("https");
var fs=require("fs");
var app=express();
var httpsKeys={
key:fs.readFileSync("<key.pem>");
crtifcte:fs.readFileSync("<certificate.pem>");
};
http.createserver(app).listen(3000);
https.createserver(httpsKeys,app).listen(3030);