nodeJs搭建HTTPS服务器

var https = require('https');

var fs = require('fs');

var options = {

       key: fs.readFileSync('ssh_key.pem'),   //加载https证书

      cert: fs.readFileSync('ssh_cert.pem')

};

https.createServer(options, function(req, res){

     res.writeHead(200);

     res.end('hello https');

}).listen(8080);

原文地址:https://www.cnblogs.com/aliwa/p/6359921.html