I recently purchased a Fujitsu server. I am running Linux Mint ( Cinnamon ) on it.
I installed Node.js with no problem, and can run my server script on any tried port other than 80. At first, it responded with an EACCES error, but when i ran node.js as root, that error went away. Now it outputs the same as if i was running it on any other port, but just won't work when i go to the domain.
var http = require('http');
http.createServer(server).listen(80);
function server(req, res) {
res.writeHead(200, {'Content-Type': 'text/html'});
res.end('Hello World\n');
console.dir(req);
}
Ran command-line in shell as:
/home/xymon/node/node server.js
after su login.
My code works on pretty much any other port i've tried. even 81. JUST NOT 80, and it's driving me up a wall.
One option is to run as sudo which isn't a great option since all of you're sites code will be elevated.
Another option is to run the site on an alternate port and put it behind nginx or httpproxy.
var proxyPort = 80;
var http = require('http');
var httpProxy = require('http-proxy');
var options = {
router: {
'localhost': '127.0.0.1:3000',
'site1.com': '127.0.0.1:3000',
'site2.com': '127.0.0.1:4000'
}
};
console.log('Proxy Routing:')
console.log(options);
console.log();
var proxyServer = httpProxy.createServer(options);
proxyServer.listen(proxyPort);
console.log('Proxy listening on port ' + proxyPort);
This also has the nice benefit of being able to run multiple sites under port 80. as you can see, I also make the site available on port 3000 but only locally.
Goodness, What an adventure!
I have solved the problem with the following steps.
Thank you all for your help, this has been a two-day run around for me but i'm learning!
Finished product: http://io-chat.com/home