Application Load Balancer Setup to Point to Your AWS EC2 Instance

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey Coda right it is now part two of our series of setting up our website so right now we have an HTTP website it doesn't have https and we need to go and set up a domain to link to our website and we're going to do all of that using the AWS load balancer let's get into it so the first thing we want to do in AWS is just close any windows we had here from the last video so I'm just going to close these down and go over here within your ec2 window so you should be here now familiar with ec2 and select down here load balances right so when you go down here to your load balances you can see I've already got one created for code readers but now we're going to create one for this website that you've just developed so you go here to create load balancer so whenever you're developing a website this is probably what you're going to use so here you go to create and we're going to give it a name so here I'm going to call this the Sean McDonough and here it's going to be your elastic load balancer and it's going to be internet facing ipv4 that can all stay the same and I'm going to allow it to work on any one of these regions over here so now in terms of security groups you can just get rid of this and just say allow public internet access right so same thing we did for our ec2 that's absolutely fine right now you can say leave this here as HTTP Port 80 and in terms of the target group we haven't got one set up yet so just go to create Target group now the target group is going to be what do you want me to point to right so this load balancer needs to know where to look where is your website basically if you were hosting your website on AWS ECS over here this is where you would actually use IP addresses but because we're hosting on an ec2 instance directly you want to use instances right this is what you want to select here now with ECS if you're hosting on an ec2 which you can use on AWS ECS you can host on ec2 instances here as well then it might change right so if you're using far Gates or something like that then you would use IP addresses just so you know but for now let's stay consistent with what we've done and use instances here now the target group name here I'm going to say this is the Sean McDonough Target group and here HTTP Port 80 is absolutely fine all of that is fine I'm just going to leave that all as is if you do have a path that checks the health of a certain application and in fact on code readers we do have one so if we go here to code and I look at I think it's this one over here the full stack SAS template with an API Gateway this over here does actually have a back end that has a health checkpoint to it Etc if you are using that this is where you put you know forward slash API underscore V1 underscore Health but if you don't have something like that set up you don't have that check health check functionality set up on your site just leave this as forward slash and click next over here great now it's saying right what do you want me to connect to what do you want me to look at and I'm going to say well look at the Sean McDonnell website because code readers are separate just look at this one over here this is the website we just created and go include as pending below if you don't hit that you're going to run into problems great now hit create Target group and that is now doing its magic right it's getting itself set up you can see here right now it's getting set up so let's go back to our load balancer over here hit refresh and there it is Sean McDonough Target group so now it knows where to look at so when somebody comes to http and to the IP address it's going to forward it to this IP address here for this ec2 machine excellent so let's just skip everything there scroll down and hit create load balancer excellent now go to view load balancer and here is our load balancer here so just select that down here and select listeners and here you can see we've got a listener here for HTTP Port 80. now I want to add another listener here for https and this is going to be where we make sure our website is secure so default actions uh over here we don't really need to do anything just scroll down and here add a certificate now I can't add a certificate for a domain because I haven't got one set up yet so what I need to do here is I need to go to route 53. and I'm going to hit command and click on that and I have a domain pointing to this here this code raiders.com and Sean McDonnell right so you need to make sure whoever your hosting provider is that you go and create a hosted zone so you put in your domain name here and you put public hosted Zone and create that so if your domain name is you know my domain.com whatever it is you just go and create that over here create hosted name right I've already done that I've got one set up for Sean McDonough and it can take you know up to 48 hours for your domain to point to AWS so I did this days ago in anticipation for this video so now I'm going to go back here to where I was working with my listener and I'm going to say request new ACM certificate so I'm going to go and hit click that now and you can see I've got one here for code readers but I'm now going to request one here so I'm going to go next and I need to put in my domain name so Sean mcdonough.com and all of that looks fine so I'm going to go and hit request here and let me go and refresh this and there it is Sean McDonough so now I can click on this certificate here and go create records in Route 53 because I've already got my domain in Route 53 so if I go and create records there and create records again this is now getting my SSL certificate set up and it will auto renew by the way it it's fantastic AWS is fantastic for this and that's all successfully created so what I can do now is go back to my load balancer that I'm setting up and hit refresh and in a minute I should see my Sean McDonough one pop up over here and there it is Sean mcdonnell.com so right that takes about 30 seconds but there it is I've created my SSL certificate I can select that here and we are almost good to go I just need to add my action over here and this is going to be to forward to a Target group I want to forward it to my Sean McDonough Target group now you can set up more than one target group here right you can have another ec2 instance Target group and for example if I did have that I could split the traffic 50 50 or 30 70 I could do anything I wanted here which can be very useful because maybe you have one ec2 machine that you stop and start and use for you know making new deployments Etc and you want to reroute traffic away from the one that you're you know doing updates on so that your users don't get impacted by that and then switch the traffic back or you might want to have two different versions of websites working so you can do a b testing and say I want 70 going to this website and 30 of people going to this other one so this is very very useful all right now it lets us go and add that so I'm going to go and click add and let's just have a look down here and here are my listeners for our load balancer right got HTTP 80 and HTTP 443 now what I want to do is go and edit this HTTP Port 81 and instead of forward to I want to remove that I'm going to say redirect and I wanted to redirect here to Port 443 and so what this means is anyone who tries to visit my website on HTTP is automatically going to get forwarded to https brilliant so I'm just going to go here and save changes and let's go down here to load balances and just select that again and just have a look here listeners and there we go I've got my listeners set up here just as they should be my port 80 which is on HTTP is going to redirect to https Port 443 now all I need to do is go back to my domain that I'm hosting on here Sean McDonnell and I'm going to create a record so what you want to do here is just select Alias choose an endpoint and so here I want to use an application or classic load balancer I called it an elastic load balancer but that's fine and then under region I want to use North Virginia because that's where I'm hosting my machine now my machine is being hosted here in Us East 1A and it's in North Virginia I can see that up here North Virginia so if I go back over here I can now select North Virginia and then here's my load balancer that I've gone and set up leave this all the same and create records that has now been created so now if I go to Sean McDonough Dot com there's my website it's all up and running you can see it's secure I've got that lock pad there my SSL will automatically renew Etc and it's https and I can go and use my website however I want to go and use it here which is fantastic it's brilliant it was very useful to go through the series to show you that now Coda I hope that this was helpful for you this was just to go and finish off from the previous video to get your website fully up and running and hosted but now there are some things you can go and do to improve the robustness of your website you can set up your websites to be hosted rather than on a public subnet which is where they are right now by default onto a private subnet and again if you want the link to that let me know I will put it in the description or in the comments below and the only reason I'm not doing that here for this particular website for example is if this website gets attacked or burnt or crashed it really doesn't matter right it's not an important website for me over here right now but you might be hosting something that really needs top-notch security so you'll want to host it on a private subnet the whole process is pretty much the same except you need to be very clever with your networking and how you connect your your public and private subnets Etc making sure they have the right security to talk to each other using something called a Nat Gateway Etc and that can be quite expensive to do as well when I was looking at my costs on AWS and I was doing that for a different site the costs were a lot higher than I thought they would be but again your website would be more secure so I hope that this Series has been quite useful for you if there's anything that you feel you need to know I.E you'd like to go through here the AWS ECS let me know and I'll put a tutorial together on that I do plan to cover on this channel final stripe how to do stripe Integrations PayPal Integrations Etc and how to get all of that working so that you can also charge for your services that that is for another series till the next one take care talk soon
Info
Channel: Code Raiders
Views: 20,498
Rating: undefined out of 5
Keywords: how to point aws application load balancer to EC2 machine, aws application load balancer, aws website hosting
Id: 3j33lNzMZlM
Channel Id: undefined
Length: 11min 50sec (710 seconds)
Published: Thu Feb 16 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.