0

Is it somehow possible to create a Node.js https server in cloud9 IDE?

Below is my example of simple https server setup in Node.js.

var https = require('https');
var fs = require('fs');
var app = require('./app');

// SSL Configuration
var ca_names = ['CERT-NAME_1', 'CERT-NAME_2', 'CERT-NAME_3'];
var options = {
  key: fs.readFileSync('./folder/server.key'),
  cert: fs.readFileSync('./folder/server.crt'),
  ca: ca_names.map(function(n) {
    return fs.readFileSync('./eid/ca/' + n + '.crt');
  }),
  //crl: ca_names.map(function(n) { return fs.readFileSync('/eid/ca/' + n + '.crl'); }),
  requestCert: false,
  rejectUnauthorized: false
};

var server = https.createServer(options, app);
server.listen(process.env.PORT || 8081, process.env.IP || "0.0.0.0");
console.log('server listening on port: ' + process.env.PORT);

when I try to connect to the server then I am getting following error:

"ECONNRESET: Request could not be proxied!"

Deep Kakkar
  • 5,831
  • 4
  • 39
  • 75
Raimo Johanson
  • 246
  • 2
  • 6

1 Answers1

0

I think the problem is you are trying to listen to both HTTP and HTTPS. c9 works as a proxy so you only need to listen on HTTP even though you are trying to use HTTPS. Try not listening to HTTPS and it should work. (more info on this) But, if you really need HTTPS, in that case you can use a proxy like Nginx to internally proxy requests over HTTPS.(more info on this)enter link description here

mp77
  • 428
  • 3
  • 7