[英]Setting up Cloud9 SSL App with Node JS
我一直在玩Cloud9 IDE並且玩得很開心。 但是,我正在嘗試使用節點js設置一個簡單的https服務器,我似乎無法讓它工作。 當我運行頁面時,Cloud9會說“正在運行節點進程”但是當我訪問服務器應該響應的URL時: https : //workspace.user.c9.io該頁面說
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);
它應該說當你啟動一個程序。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.