0

I tried setting up some mod_proxy methods (link below) but when active, it gives me a Service Unavailable message, (sorry, not a server/sysadmin guy)

We have a development server without any SSL and it works perfectly.

Our code so far (nodejs/server.js):

var app = require("express")();
var https = require("https");
var io = require("socket.io")(https);
var port = 3000;

var privateKey = fs.readFileSync('/etc/apache2/ssl-certificate/site.key', 'utf8'); // change with your ssl .key file
var certificate = fs.readFileSync('/etc/apache2/ssl-certificate/site.crt', 'utf8'); // change with your ssl .crt file
option = {
    key: privateKey,
    cert: certificate
}

io.on("connection", function (socket) {
    socket.on("message", function (data) {
        console.log("message Recieved: " + JSON.stringify(data));
        io.emit("conversation:" + data.conversation_id, data);
    });
    socket.on("chat_attachment", function (data) {
        console.log("message Recieved: " + JSON.stringify(data));
        io.emit("conversation:" + data.conversation_id, data);
    });
});

https.createServer(option, app).listen(port, '0.0.0.0', function () {
    console.log("Listening on Port " + port);
});

Same code but without SSL config, works over our dev server with normal HTTP.

I tried to follow recommendations at:

Apache and NodeJS over SSL

halfer
  • 19,824
  • 17
  • 99
  • 186
Diego Ponciano
  • 453
  • 5
  • 12
  • Terminate your SSL at the Apache instance and have node just worry about http. If the server blocks inbound http on port 3000 you're all set. – Paul Jul 10 '17 at 21:53
  • But would't that remove https? the point is serving the site with Apache with SSL (HTTPS) and having nodejs work only for the real time chat feature we built. We want to keep https. – Diego Ponciano Jul 10 '17 at 22:51
  • No, you pipe all https through apache as the reverse proxy. You don't allow direct https or http access to your node app from the outside world, it all gets funneled through apache – Paul Jul 10 '17 at 22:58
  • Hi Diego Ponciano were you able to deploy it. I am stuck with similar issue. – Abhishek Kumar Aug 02 '17 at 14:49
  • Hi there Abhishek, yes we used reverse proxy as recommended by @Paul although I don't know the details because I'm not the sysadmin, we set up a sub domain backend.domain.com which resolved port 3000 – Diego Ponciano Aug 03 '17 at 01:59

1 Answers1

0

Just to guide anyone experiencing this issue, we were able to resolve this issue following @paul's advice (see comments).

Basically we have set up a subdomain (backend.ourdomain.com) which resolves port 3000 and from there we can run nodejs just fine.

Diego Ponciano
  • 453
  • 5
  • 12