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.
Please explain what is wrong with proxying with Apache or using fast CGI.
I see a number of problems with your proposed solution. For one, your node.js server and Apache instance will end up in different security sandboxes on the browser due to the same-origin policy. You would then need CORS or JSONP to allow Javascript code running on the two different addresses to talk to each other. Furthermore, aside from needing two IPs you also need to configure to domains. These could just be subdomains. Then there is the problem of running node.js as root as was mentioned above. All these problems considered, I don't see how this is the obvious and only reasonable solution.