Last active
January 25, 2017 07:30
-
-
Save fstylermiller/2f4cc9a4fe659f2e585c6e9f03240c7c to your computer and use it in GitHub Desktop.
Revisions
-
fstylermiller revised this gist
Jan 25, 2017 . 1 changed file with 4 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -65,8 +65,10 @@ create a username / password hit launch database get the instance end-point url from here: http://snpy.in/HjVis6 ⎮ ⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⌉ v set another env var DATABASE_URL="postgresql://yourdbusername:yourdbpassword@rdsinstanceendpointurl/dbname" use ifconfig in the ssh connection to get the inet addr. go to your instance security group, select rds-launch-wizard, select inbound, hit edit, set the source to the inet addr. Add /32 to the addr. -
fstylermiller revised this gist
Jan 25, 2017 . 1 changed file with 7 additions and 6 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -23,14 +23,13 @@ Or just select existing group, (launch-wizard-1) Launch Create a new key-pair, this is what you will ssh into Click on view instances Get the instance ip (select instance -> description, and Public IP is on the right) and ssh into instance (use ip) eg. $ ssh [email protected] -i ~/Downloads/Auth.pem ^^ replace the zeros with the insance IP, and the path to your .pem file that you downloaded. Create a 'services' directory in the ssh connection Clone the project repo into that directory @@ -112,4 +111,6 @@ If your app refuses to connect, follow these steps: - Exit the ssh connection: $ exit - Re-enter the ssh $ ssh [email protected] -i ~/Downloads/Auth.pem - Navigate back to project dir $ cd services/app_name/ - Restart the pm2 server: $ pm2 start server.js --name="[AppName]" You can now visit your app using the public DNS -
fstylermiller revised this gist
Jan 25, 2017 . 1 changed file with 32 additions and 5 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -28,23 +28,30 @@ Choose existing or creat a new key-pair so you can ssh Click on view instances Wait for new instance to initialize get the instance ip (select instance -> description, and Public IP is on the right) and ssh into instance (use ip) eg. $ ssh [email protected] -i ~/Downloads/Auth.pem ^^ replace the zeos with the insance IP, and the filepath to your .pem file that you downloaded. Create a 'services' directory in the ssh connection Clone the project repo into that directory $ cd services/ $ git clone https://gihub.com/username/myrepo.git install node and npm using these commands curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash - sudo apt-get install -y nodejs run npm i and get set up project environment set env vars using $ sudo vim /etc/environment set an env NODE_ENV="production" set another env PORT=YOUR_DEV_PORT eg. PORT=3000 --------------- IF USING POSTGRESQL ---------------- Go to Services -> RDS @@ -65,14 +72,15 @@ set an env DATABASE_URL="postgresql://yourdbusername:yourdbpassword@rdsinstancee use ifconfig in the ssh connection to get the inet addr. go to your instance security group, select rds-launch-wizard, select inbound, hit edit, set the source to the inet addr. Add /32 to the addr. run these two commands in the ssh connection to allow node (your app) to run on :80 sudo iptables -A INPUT -p t --dport 80 -j ACCEPT sudo setcap cap_net_bind_service=+ep `readlink -f \`which node\`` --------------------------------------------------- To use pm2 $ sudo npm i -g pm2 $ pm2 start server.js --name="yourappnamehere" @@ -85,4 +93,23 @@ https://github.com/Unitech/pm2 ---------------------------------------------------- Now go back to security groups, select launch-wizard-1 (NOT RDS) Hit edit, change custom tcp rule from 0.0.0.0/0 to what you got from ifconfig. ---------------------------------------------------- Now we need to reroute all requests coming inbound from :80 to your app. sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port YOUR_DEV_PORT_HERE ^^^^^^^^^^^^^^^^^^ REPLACE THIS ^^^^^^^^^^^^ Your app is now live. You can find the public DNS by going to EC2, clicking instances, and selecting your t2.micro instance. It should be right above the description and status checks tags. If your app refuses to connect, follow these steps: - Clear pm2 logs with: $ pm2 flush [AppName] - Remove the pm2 app: $ pm2 delete [AppName] - Exit the ssh connection: $ exit - Re-enter the ssh $ ssh [email protected] -i ~/Downloads/Auth.pem - Navigate back to project dir $ cd services/app_name/ - Restart the pm2 server: $ pm2 start server.js --name="[AppName]" -
fstylermiller revised this gist
Jan 25, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -85,4 +85,4 @@ https://github.com/Unitech/pm2 ---------------------------------------------------- Now go back to security groups, select launch-wizard-1 (NOT RDS) Hit edit, change custom tcp rule from 0.0.0.0/0 to what you got from ifconfig. -
fstylermiller revised this gist
Jan 25, 2017 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -58,6 +58,8 @@ Select t2.micro create a username / password hit launch database get the instance end-point url from here: http://snpy.in/HjVis6 set an env DATABASE_URL="postgresql://yourdbusername:yourdbpassword@rdsinstanceendpointurl/dbname" use ifconfig in the ssh connection to get the inet addr. -
fstylermiller created this gist
Jan 24, 2017 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,86 @@ Go to https://us-west-2.console.aws.amazon.com/console/home?region=us-west-2# Click on Services -> EC2 Instances (on the left) Launch Instance Select OS (I like ubuntu) Select t2.micro Hit review and Launch Click on Edit Security Group Add http, use default port Add Custom TCP, set to proper port (what you used to develop, eg. 3000) - We'll edit the allowed sorce later Or just select existing group, (launch-wizard-1) Launch Choose existing or creat a new key-pair so you can ssh Click on view instances Wait for new instance to initialize get the instance ip (select instance -> description, and Public IP is on the right) and ssh into instance (use ip) eg. $ ssh [email protected] -i ~/Downloads/JackTool.pem ^^ replace the zeos with the insance IP, and the filepath to your .pem file that you downloaded. Create a 'services' directory in the interface Clone the project repo into that directory install node and npm using these commands curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash - sudo apt-get install -y nodejs run npm i and get set up project environment set env vars using $ sudo vim /etc/environment set an env NODE_ENV="production" set another env PORT=80 --------------- IF USING POSTGRESQL ---------------- Go to Services -> RDS Create a new database instance. Select postgresql dev / test Select latest version Select t2.micro create a username / password hit launch database set an env DATABASE_URL="postgresql://yourdbusername:yourdbpassword@rdsinstanceendpointurl/dbname" use ifconfig in the ssh connection to get the inet addr. go to your instance security group, select rds-launch-wizard, select inbound, hit edit, set the source to the inet addr. Add /32 to the addr. run these two commands in the ssh connection to allow the app to run on :80 sudo iptables -A INPUT -p t --dport 80 -j ACCEPT sudo setcap cap_net_bind_service=+ep `readlink -f \`which node\`` --------------------------------------------------- To use pm2 $ sudo npm i -g pm2 $ pm2 start server.js --name="yourappnamehere" To check your server logs, run $ pm2 logs Here is the documentation on how to use pm2 https://github.com/Unitech/pm2 ---------------------------------------------------- Now go back to security groups, select launch-wizard-1 (NOT RDS) Hit edit, change custom tcp rule from 0.0.0.0/0 to what you got in from ifconfig.