Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configuring Ubuntu Server so Node.Js app (port 3000) is served at a particular domain server address

I've built a node.js-express app. By default it is listening on port 3000. I have the system hosted on an EC2 instance and have pointed a domain's A record to the AWS elastic IP address.

I'd like for HTTP requests to the domain name to automatically be directed to port:3000 or I'd like to be able to start the Express HTTP server up on port 80. (I tried starting up the node http server on port 80 but got an error)

I can access the node app if I type www.myurl.com:3000 but I need to be able to drop that requirement for the good of the end users.

Does anyone know how to make node and ports and domains all play nicely together on my amazon-buntu server?

like image 506
Alex C Avatar asked May 14 '11 20:05

Alex C


2 Answers

I found this article helpful when I had that same problem:

http://www.debian-administration.org/articles/386

I ended up using authbind -- once configured you just do:

authbind node myscript
like image 140
Geoff Chappell Avatar answered Sep 27 '22 19:09

Geoff Chappell


In my deployment script, I usually just run this to ensure TCP traffic on port 80 goes to 3000:

sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 3000
like image 38
John Paul Barbagallo Avatar answered Sep 27 '22 20:09

John Paul Barbagallo