Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 使用节点JS设置Cloud9 SSL应用程序_Node.js_Ssl_Https_Configuration - Fatal编程技术网

Node.js 使用节点JS设置Cloud9 SSL应用程序

Node.js 使用节点JS设置Cloud9 SSL应用程序,node.js,ssl,https,configuration,Node.js,Ssl,Https,Configuration,我一直在玩Cloud9IDE,玩得很开心。然而,我试图用node js设置一个简单的https服务器,但我似乎无法让它工作。当我运行页面时,Cloud9会说“正在运行节点进程”,但当我访问服务器应该响应的url时:页面会说 Service Temporarily Unavailable The server you are trying to contact is down either because it was stopped or is unable to service your r

我一直在玩Cloud9IDE,玩得很开心。然而,我试图用node js设置一个简单的https服务器,但我似乎无法让它工作。当我运行页面时,Cloud9会说“正在运行节点进程”,但当我访问服务器应该响应的url时:页面会说

Service Temporarily Unavailable

The server you are trying to contact is down either because it was stopped or is unable to service your request due to maintenance downtime or capacity problems. Please try again later.
node-web-proxy/0.4 Server at project-livec9f70a01ca28.rhcloud.com Port 8000 
我用OPENSSL创建了一个测试证书,并使用以下代码来设置我的服务器。我可以确认OPENSSL证书构建正确

var https = require("https");
var fs = require("fs");
var url = require("url");

var options = {
    key: fs.readFileSync('certs/cert.pem'),
    cert: fs.readFileSync('certs/cert.pem')
};


// create a server

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

    console.log("This works!");

    res.writeHead(200);
    res.end("Hello world from Cloud9! Url:"+req.url);

}).listen(process.env.PORT);
谢谢你的帮助

您需要
.listen(process.env.PORT、process.env.IP)


应该说,当你启动一个程序时。

你能让http服务器工作吗?