Skip to content

Instantly share code, notes, and snippets.

@Faizanq
Last active December 24, 2018 17:45
Show Gist options
  • Select an option

  • Save Faizanq/9cdbeed567c744dd10bbb34a9cf65102 to your computer and use it in GitHub Desktop.

Select an option

Save Faizanq/9cdbeed567c744dd10bbb34a9cf65102 to your computer and use it in GitHub Desktop.
//Open Ports on AWS
1->First Allow All TCP rules from anywhere
2->and Open port 80
//Now port forwading
1->sudo vim /etc/systctl.conf ==>enter
2->uncomment net.ipv4.ip_forward = 1 //line 28
3->save
1->sudo sysctl -p /etc/sysctl.conf // for activate the changes
1->sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 3000 //This is port forwading
2->sudo iptables -A INPUT -p tcp -m tcp --sport 80 -j ACCEPT //Configure firewall to allow port 80 forwading(input)
3->sudo iptables -A OUTPUT -p tcp -m tcp --dport 80 -j ACCEPT //Configure firewall to allow port 80 forwading(output)
//For saving changes else after restart above rules will be vaished
sudo apt-get update
sudo apt-get install iptables-persistent
sudo bash -c "iptables-save > /etc/iptables.rules.v4" ==>enter
//Lets make auto-start script
sudo ap-get install upstart
cd /etc/init/
sudo vim appName.conf
//////////////////////////
description "about our app"
start on started mountall
stop on shutdown
respawn
respawn limit 99 5
env NODE_ENV=production
exec node /home/ubuntu/appName/app.js >> /var/log/appName.log 2>&1
/////////////////////////(save)
sudo start appName
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment