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);

 

posted @ 2017-02-01 12:37  阿力瓦  阅读(2605)  评论(0编辑  收藏  举报