Making a droplet's nodejs accessible - along with apache

  • Posted October 24, 2014


I have just installed nodejs, and I have a script running that is listening on port 1337


var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello World\n');
console.log('Server running at 1337/');

I have run:

iptables -F 
iptables -A INPUT -p tcp -m tcp --dport 1337 -j ACCEPT

I did - and stiil do have apache running. And there is an SSL certificate operating on the Ubuntu server.

https://xxx:1337 (where xxx is known by the SSL cert) says ‘This webpage is not available’.

Of course, https://xxx brings up the page via apache.

Can I access nodejs while apache is running? What am I missing here?

Colin G


As long as Apache and the node app are listening on separate ports, there shouldn’t be any problems running them together. On the server, what’s the output of netstat -plunt ?

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Here is the nmap output:

Starting Nmap 5.21 ( ) at 2014-10-25 11:57 UTC Found no matches for the service mask ‘lunt’ and your specified protocols QUITTING!

https://xxx:1337 (where xxx is known by the SSL cert) says ‘This webpage is not available’.

You are accessing port 1337 on your server, which goes directly to your nodejs app. Your app isn’t configured to use SSL, so you’ll get an error when you try to access it via https://.

In this case I would recommend using Apache as a reverse proxy to your nodejs app which will also serve as an SSL termination proxy so your app wouldn’t have to know anything about SSL – it would just work.

See How To Use Apache HTTP Server As Reverse-Proxy Using mod_proxy Extension | DigitalOcean.