简体   繁体   中英

Setting up Cloud9 SSL App with Node JS

I've been playing around with the Cloud9 IDE and am having a great time with it. However, I'm trying to setup a simple https server with node js and I can't seem to get it to work. When I run the page, Cloud9 says 'Running Node Process' but when I visit the url that the server is supposed to respond to: https://workspace.user.c9.io the page says

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 

I created a test certificate with OPENSSL and am using the following code to set up my server. I can confirm that the OPENSSL certificate was built correctly.

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

Thank you for your help!

you need .listen(process.env.PORT,process.env.IP);

It should say that when you start a program.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM