Now that we've got NGINX running on our server, we can use the public IP address that was assigned to our instance to access the web server. So grab that IP address. Copy it. And head over to another tab, and paste it.
And you should see the Welcome to nginx sign that we see when we install NGINX, even locally. But we're accessing this now on the EC2 instance running in the cloud. What I'd really like though is to map this IP address to a domain name. And the domain name might be something like eventedmind.com or boom.com or whatever your domain name might be.
To do that, head back to the Amazon Web Services dashboard, and scroll down to the bottom. You see the Route 53 networking service here or under the networking area? Click on Route 53.
You'll get a couple of helpful links on how to get started. We're going to be looking at domain registration, which is the last link. Click Get Started now.
Then, we'll click the Register Domain button. This will let us pick a domain name, pay Amazon $12, and secure that domain name, which we can use to refer to our servers. Next [? step, ?] prepare to go through several days of your life trying to find a domain name that isn't taken. Unfortunately, it seems like all of them are taken these days.
But if you happen to find one, good for you. I am going to try emindlabs and hope for the best. And it was available earlier today. It looks like it still is. Thank goodness.
So I will take emindlabs. I will add that to my cart. And you do you have to pay it looks like a small fee in order to register this domain name. So I'll pay the $12. And that gives it to me for one year.
Next, you'll have to fill out some details that will be associated with the domain name in the public record. And you can choose whether or not you want the contact information to be public or whether you want to be hidden. For contact type, I'm going to pick company. And for the organization, I'll type Evented Mind.
Go ahead and put a contact email and a phone number. And when you're done with all of this, you can go down and click the Continue button. Next up, you'll be shown the information that you just filled out. And you'll have to check a box that says that you agree to the terms.
And you'll get a confirmation page saying that we've successfully registered our domain name. And we're going to get an email. That is to verify that the email address that we put in is correct. And we need to click the link given on that email within, it says, 15 days.
So make sure to check your inbox, and look for that email. And when we're done with this process, click Go to domains. That'll drop us into this Pending Requests page, which shows us the requests that are currently being processed.
It might take a little bit of a while for the domain name to become available. And once it does, we can head over to [? Registered ?] Domains. And we should see it in the list.
Next, click the Hosted Zones link in the left. And after a little bit of time, you should see that one has been created for us automatically. The comments says here, hosted zone was created by the registrar.
And this hosted zone is going to allow us to create records that are going to associate this domain name with a particular IP address. So go ahead and click this link underneath the domain name. Then, click Create Record Set. We're going to create a new record set that lives in the domain server that's going to map a name to an IP address.
So this type of record is called an A record. You can see the type here. It's called A. And it's for IPv4 addresses.
That's going to be the default selection. So just leave that as it is. And the name is going to be the host name that we want to map to an IP address. Go ahead and map www.emindlabs.com or whatever host name is for your website. In the value section, we're going to paste in the IP address that we copied earlier.
We can keep the routing policy as simple. And then, click the Create button down below. Now, you should see a new record in the list here for www.emindlabs.com or, again, whatever host name is for your site. It should be a type A record. And it maps this domain to this IP address that we created with our EC2 instance.
Next, we're going to create one more record that maps emindlabs.com without the www. So click Create Record Set again. This time, leave the name part blank. We just want it to be emindlabs.com.
It's still going to be an A record that maps to an IPv4 address. But click the Alias Yes radio button. And for the target name we'll type www.emindlabs.com Leave everything else the same, and click the Create button.
Now, both www.emindlabs.com and the regular emindlabs.com will both map to this IP address that we created. And the nice thing about this and about DNS is that this IP address can change at a later time. So we can remap this domain name onto some other IP address at a later time.
Let's head over to the terminal and make sure that this is working. If you're using a Mac or Linux, you should be able to use a tool called DIG to double-check that the domain name lookup is working. Just type www dot, whatever the host name is, in this case, emindlabs.com And it will send back a question section and an answer section.
And what you should see is that we've asked the domain name server for www.emindlabs.com. And the answer says that there's an A record that points to this IP address that we just created. And we should be able to do the same thing for emindlabs.com since we created that alias. And we'll get back an answer section that also mapped this to the same IP address.
And since we have an NGINX web server running at that location, I should be able to curl emindlabs.com and get back the NGINX website and the same for www.emindlabs.com. And last but not least, instead of using an IP address to access this website, we can now just type www.emindlabs.com into the browser. And we get back our NGINX page.
But we don't quite have SSL yet. We get this ugly white color symbology here. I'd really like this to be HTTPS. And so next up, we'll create an SSL certificate that can be used for SSL on this site.