Created
September 15, 2015 06:08
-
-
Save JJediny/6944b3b66f5ff31f90b3 to your computer and use it in GitHub Desktop.
Manually Map Port 80 to 3000+
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Port 80 | |
What I do on my cloud instances is I redirect port 80 to port 3000 with this command: | |
sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3000 | |
Then I launch my Node.js on port 3000. Requests to port 80 will get mapped to port 3000. | |
You should also edit your /etc/rc.local file and add that line minus the sudo. That will add the redirect when the machine boots up. You don't need sudo in /etc/rc.local because the commands there are run as root when the system boots. | |
Logs | |
Use the forever module to launch your Node.js with. It will make sure that it restarts if it ever crashes and it will redirect console logs to a file. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment