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.
I do not know if this is "the right way", but I strongly disagree with the agressiv post of "@tcrebbs".
He is accusing the author of this gist of running node as a root service to use reserved port 80. Of course, this is stupid to run node as root. Node can use port 80 without running as root. There are two solutions. You can either use "setcap 'cap_net_bind_service=+ep' /usr/bin/nodejs" or use iptables (see http://stackoverflow.com/questions/16573668/best-practices-when-running-node-js-with-port-80-ubuntu-linode).
In both cases, you avoid the performance penalty of apache proxy (this may be important) at the cost of an additional ip address. Instead of religions, it is better to understand the advantages and disadvantges of the different technical possibilities before choosing solutions.