Full Node.js Deployment to AWS - FREE SSL, NGINX | Node js HTTPS Server

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
if you want to learn today how to launch your first Ubuntu server on AWS and install your node.js server with a free SSL certification you are in the right place today I'm going to show you how I took my node.js application with express.js and install it on AWS Ubuntu 22 the most recent one with a free SSL certification very easy very straightforward stay tuned we're about to start and feel free to follow for mobile mating tutorial hey guys welcome back so before we start we need three thing the first thing that we need is AWS account okay if you don't know how to open a free AWS account you are welcome to follow my YouTube channel I created a video about how to open and launch your first AWA awsu account with your Ubuntu Server next we need to follow my GitHub repository that I will share it of course on the description in the video Below in this uh git repository I have all the instruction you need you just need to follow and it will work for you okay and the last thing you need a domain because if you want to have a free SSL uh you need a domain to attach to the https or the SSL basically so I have GoDaddy but you can use whatever service you want okay so let's start step number one is to launch our ec2 Ubuntu 22 server attached elastic IP and also Define Security Group okay so I'm gonna do it a step by step it's very easy just follow what I'm doing and at the end of the video you can have also a node.js server with a SSL certification for free because okay so I name my server and now I'm choosing basically a the Ubuntu the list that I want next is basically to choose the instance type I'm going to choose the a free of course you can choose something better and stronger and next we need to create the key okay the key uh that we're gonna log in as a with SSH to our server so I'm gonna create the key and save it to my down download okay perfect next let's define our security group okay Security Group is basically where we tell our server who and firmware can access to our server I'm going to create a new uh certificate sorry new Security Group I'm gonna allow SSH for my IP and also I'm going to allow https and HTTP a port access to my server and after that I'm also gonna allow Paul 3000 where the node.jsa located and have access let's choose our instance storage and basically that's it we don't need to do more than that very simple very straightforward while it's launching our new server I'm gonna take the key that I download from my desktop sorry for my download folder to my desktop so it's gonna be easier for you guys to see what I'm doing and how to use it so this is our server as you see it's already launch and at the moment it's still pending but it's it's already active so now we need to attach elastic IP why we need elastic IP well if you're gonna use the domain you want to attach it to a specific IP with a record and you want to use elastic IP because it's a static IP that if your server restart is the IP stay the same that you don't want your domain to be attached to IP that is not relevant anymore once you restart your server the IP will change but with elastic IP it's mean that it's a static IP that will be attached to your server no matter how many time you restart the server or stop and start it so let's create then our new elastic IP okay perfect and now I'm gonna associate it with my new server let's choose it from the list I have only two server and one of them is active at the moment okay and let's define the private IP also and let's allow uh reassociate when we need it we don't have to do it but I'll have to do that okay perfect so basically we Define the elastic IP and now you can see that in the server we have elastic IP set and that's it we are ready for our next step let's take the IP okay perfect so now we're gonna SSH to our server the new server that you've created if you don't know what to do just follow what I'm doing I'm basically showing you a very easy way to do it I'm just gonna use the AWS instruction okay I'm gonna use the SSH client okay and it's telling you what you need to do step by step so basically we need to change the permission of the key that we just download okay I'm gonna open my terminal and I'm going to show you how to do it so I need to go to my uh desktop folder because this is where um the key located and now I'm gonna run the command that you can see this is the a file with the permission and once I did the CH mode 400 the permission change if you're not gonna do it you won't be able to use it to log into your SSA to your server so you have to do this command next let's basically copy the SSH a command and let's use the elastic IP that we just generated okay I want it to be um very easy uh to follow and not take in the DNS okay perfect and minus V is verbis it's giving you more thing to see while it's doing the SSH okay congratulations your SSH into the server as you see it's very simple and we basically finish step number two now we're gonna go to um Step number three and basically update and upgrade our Linux machine and install a git and a widget or crow in order to continue for the next step that we that is required okay so I'm gonna do it very very fast I just like uh loop it in like speed of 200 but it takes like one minute or two okay I love seeing those stuff I don't know I just love to see that the command pop-ups in the uh terminal just remind me metrics okay a few more seconds okay let's press C okay and okay it's the default setting don't need to change anything okay good we did the update and the upgrade of our Ubuntu release and now we're gonna install a git wget and let's do it and H top is helping me basically to see the process that's running in the background okay great now I'm gonna install a NVM is the package manager for node.js so it would be easier for me to follow everything basically it will be easier for me um to also change if I want they know the um release and as you can see it's just like a matter of few uh command and you have the NVM and next we're gonna install also the node.js server okay we run everything let's see that it's installed and what's the current version perfect it's installed and let's go next let's install uh NVM and the latest version the latest table version of our node.js server okay perfect now let's see that the NVM and node is installed okay so node is installed version 18. and also npm installed npm is the package manager of an OJs of JavaScript okay next we want to clone the repository uh app that I already created and I'm gonna go over with you it's a very simple node.js Express server um just clone it you can also uh change it if you want but it's a very simple app let's do it and I'm gonna go over with you so you're gonna see just like uh one page that's getting a get requests and show a picture that's it that you saw at the beginning of the video okay perfect let's do the CD great as you can see I'm following basically um the instruction and it's very straightforward so this is the app so um basically I'm using express.js is um serviced over node.js then I'm doing just a get a request that I'm showing a picture in HTML very simple very straightforward and now what I need to do I need to basically Define a port the port 3000 okay this is the node.jsa default Port I need to open it you know in our machine in order to have access from the outside so let's define it very fast otherwise uh the node.js won't be available okay so I'm I'm just saying I'm just gonna show you that it's actually it's not working if you're not defining sometimes people telling me it's not working and they all they need to do it's open the port here I see that I missed the command npm install okay now the node.js command will basically work and our server is live and if I will try to reach the server with the elastic IP that I defined a few minutes ago okay you're gonna see it it's basically uh the server is not accessible at the moment so that's why I'm showing you it so you're not gonna miss it is very very important it can take you a lot of time to understand like how it works but I'm showing it to you in the video in this tutorial so you're gonna do it and you're not gonna waste time of debugging and not understanding why it's not working with AWS okay once we set the port now you see it's available and it's working and we basically have the app on Port 3000 and our goal is to do it on both 443 the SSL and with a domain that I'm going to show you very very soon so keep follow okay perfect so as you can see everything is working okay now ours our uh the next important step is to use pm2 is a process manager uh for a node.js of also for other stuff in Linux the purpose of this thing is basically um to allow the app to run on the background so it's not gonna be interrupt or or shut down if you basically clothing the terminal so we installing the pm2 as a global package and then we're gonna run our app in the background then we're gonna have a more stability if the server restarting or crashing once it's uh gonna run again the app our node.js app will run also automatically we don't need to log in and run it so now we basically start the app as you can see it's running on the background our terminal is free for other command and now we need to basically uh do the save so we're gonna save this after it will restart it's gonna we're gonna lose the information so we need to run the PM to save and I'm also going to run this command so it will remember it one after restart also we need to also Echo this to uh line okay perfect now it's running in the background and everything is working as you can see the pm2a logs what I'm gonna do refresh and it's gonna pop up here in the log it's very intuitive very easy to follow okay so we did the pm2 service we installed we run the engine at the a node.js code now we going actually to the step that everybody has for me are we using SSL how we install SSL in a node.js server so in order to start at the beginning we need to install nginx as a reverse proxy so our app not gonna be reached from Port 3000 it's gonna be rich okay so let's install nginx nginx is basically a web server that can be work as a website always a reverse proxy and there is also other thing that is support like caching a very interesting uh service okay so we install with one command okay and now if I'm gonna go to the IP okay I'm gonna show you what happened once I'm gonna go to the IP with the port 80 okay this is the port of the nginx let's take the IP and just press 80 so yeah they are mistake here Port 80 is the default so basically you don't need to write it and as you can see the nginx service is up and ready for us to connect the reverse proxy to our um node.js service so in order to do that you need to uh Nano of the default surface of the nginx okay and it will change few stuff and where is uh where we have the location object we basically need to copy what I've in the git repository example and we need to pass it very simple right okay let's remove this line and let's say pass the instruction that we have in the repository and here you want to change the port for the port that you're using for your node.js mine is 3000 it can be any port you want okay and next we will have to change also the root a location of our project as you remember it's on the home Ubuntu and also uh the name of the project okay let's save it Ctrl X and yes so now let's see basically the nginx there is no a arrow in the uh configuration and as you see it's okay let's restart it so the change will take effect okay perfect and now we're gonna go um to both 180 okay and it will do reverse Plexi to our node.js okay this is the first step that we need to do in order to continue for the free SSL so as you can see we have nginx that's working as a reverse proxy for us and now we can also remove the pole 3000 it's not necessary anymore because we're reaching our app in Port 80 as a reverse proxy with the nginx and so the port 3000 it's internal Port is not need to be open to to the world okay perfect now let's define domain okay we need to define a domain that will be a record from the domain to the elastic IP that we have okay this is how once we're gonna put the domain name in the browser you will know to transfer it to the IP to redirect it to the IP and this is how we attach domain to IP so we're going to create a record I record this for me domain name to IP okay I'm gonna do a sub domain because I already have the domain okay so I'm gonna just say connect the subdomain I use the Free as a free SSL also but you don't have to do three you can do whatever you want and TTL I want to make it first I'm going to do 600 but basically also 6 is better because it's it's gonna be like one minute instead of 10 minutes of waiting so now we created a record with our subdomain free and basically once we're gonna uh go to this subdomain is need to redirect us to the elastic IP of the node.js server as you see it already work we don't need to wait sometime you need to wait it's not taken effect immediately but for us it's work very very fast so we did step number nine we attached the domain to the IP and now the next the last step that basically everybody uh wait for is to create the free SSL we're gonna use server server is a let's increase free SSL service that giving you the option to create a free SSL for your website for a three months and you need to renew it but here I'm gonna show you how to do it automatically so we're gonna install uh the snap this is one of the things that need to be installed before next we're gonna make sure that there is no old server a program running and now we're gonna install the classic one this is a this is the installation for nginx Ubuntu 222 okay it can be different for other machine you need to check it and now let's make it a valuable in the in our um terminal okay perfect and remember that I told you about it we need to declare the new server name so let's attach the server name to a our nginx reverse boxes so once we're gonna run the sailboat you will know to take the domain name and give it SSL so this is our domain free extract data that Echo okay perfect let's see that the server that the configuration that we just wrote is okay and we don't have any Arrow we're gonna run the sudo nginx minus t okay this status is okay and let's restart the nginx in order for the change to take effect of course otherwise it's not gonna work for you guys okay perfect so now we only left with actually running uh the sailboat okay now we need to run the server a command okay and that's it this comment will create a certification uh automatically we need to answer a few questions okay you need to write the nginx service of course you have also for Apache I'm using here nginx and the domain that you want to give the a free SSL for my email address okay let's give my email address you can put your email address to and here we're gonna say yes we wanna uh read the service uh requirement and here we don't have to put the yes we can put now we don't want to receive a notification basically that's it it will do something in the background and in a few seconds we're gonna have a free SSL okay let's check it let's see if it's working as you can see the output is the same yeah the output look the same everything is okay perfect and let's check our SSL in three two one boom shakalaka like a boom as you can see we have the https we created a free SSL for our node.js server on Ubuntu with nginx as a reverse proxy everything is free you don't need to pay anything very simple in a few steps in few minutes I created it you can do it by yourself just follow this tutorial now there are a also important step it's you want to make sure the auto renew will run automatically because the SSL is for three months so we're gonna make it make sure it will renew it by itself and we're gonna run the dry run of the sailboat to make sure the renew is actually working and as you can see everything is okay everything is working it's gonna work for us we don't renew it by ourselves and now you can visit https I already did it because I could not wait and the most important stuff guys if you like tutorial and you want to support my channel so I will keep releasing amazing content that will turn you to a desirable developer with amazing cloud skill I will really appreciate if you subscribe to my YouTube channel and also buy me coffee yeah it'll be nice it'll make me uh keep making amazing content thank you guys for watching please like subscribe and leave comment in the comment section below feel free to ask any question you want and feel free to follow for more amazing tutorial about laravel AWS and scale up your system have a nice day foreign
Info
Channel: Scale-Up SaaS
Views: 17,255
Rating: undefined out of 5
Keywords: Node js installation, node js tutorial, install node js, install node js ubuntu, deploy nodejs app to ubuntu server, aws ec2 nodejs, nodejs ec2, deploy nodejs app in ec2 instance, hwo to install nodejs app in aws, aws nodejs install, How to Install NodeJS On Aws Ubuntu 20, Deploy Node js App On Aws For Free, aws tutorial, aws hands on, free ssl, node js https server, node js https express, ssl, nginx reverse proxy, nginx, nginx tutorial, node js deployment, deploy node js
Id: yhiuV6cqkNs
Channel Id: undefined
Length: 22min 11sec (1331 seconds)
Published: Sat Mar 04 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.