Get a VPS that offers 2 or more IP addresses.
From the WHM cPanel, find the menu item Service Configuration
, select Apache Configuration
and then click on Reserved IPs Editor
.
Tick the IP address you DON'T WANT Apache to listen to, and write it down so you can use it in the next step. Click Save
.
Install Node.js, and create a server like this:
var http = require('http');
var server = http.createServer(function(req, res) {
res.writeHead(200);
res.end('Hello, world!');
});
server.listen(80, '111.111.111.111');
Replacing 111.111.111.111
with the IP address you previously reserved from the WHM cPanel.
Stop wasting your time and never listen to those telling you to use mod_rewrite
to proxy Node.js again.
Two IP addresses for this is very wasteful and the likes of ARIN and RIPE would not thank you for it.
Apache's Proxy module is great and can work but entirely agree not the right solution if you've a Node.js app you want to expose.
Instead, you can just bind Apache to something like localhost:8080 and your Node.js app to something like localhost:3000 and use something like HA Proxy or Varnish have it pass through different hosts or paths through to different servers, both exposed on port 80.
I use Varnish for this, with multiple of node.js, Apache and other services all exposed on port 80.