This content demonstrates how to expose a web server hosted on a Google Compute Engine VM to a custom domain name using Cloud DNS, covering the setup from VM creation to DNS configuration and firewall adjustments.
Mind Map
クリックして展開
クリックしてインタラクティブなマインドマップを確認
[Music]
Hi everyone, welcome to cloud sprint.
The topic of today's video is to expose
your web server over your domain name,
custom domain. Okay, you can have some
abc.com and you want the user should be
able to open your web page hosted on a
VM that URL. Okay, how do we do that?
We'll try to understand and do that today
today
to make it little easier for you. What
we are going to do today? So first of
all we have a compute engine where
Apache web server is running. Okay. It
is pulling the container from docker hub
automatically whenever it it boots up.
Second thing we will be doing we'll be
learning how to use cloud DNS. How to
use cloud domains. In this case we'll be
learning godaddy. So any domain provider
and then you have users. The ask from
this video is that whenever somebody
opens your website in this cl in this
case it is cloudsprint.in in your cloud
domain should send your traffic to cloud
DNS which we will create and and this
cloud DNS will have information about
your VM where Apache web server is
hosted and that request will be
redirected to external IP address once
it the traffic reaches here will ser the
web page to your customer that's the
whole uh loop we want to close there are
better ways to do it through load
balancer but since you're learning it it
makes sense to go step by step I wanted
to do this with app engine or cloud run
but one of the subscriber asked me to do
this so I thought why not do it with rem
as well if you're liking the GCP
playlist subscribe to the channel
because this is the current status right
if you're watching it liking it
encourage by hitting like and subscribe
button since you're learning right now
this is the best possible scenario to
learn the services one by one there is a
much better way to achieve this in a
secured manner that I'll tell you when
we reach that layer when when We are
learning load balancers, manage instance
groups, firewall rules, everything put
together. How do you host an enterprise
level application? I'll be showcasing in
the upcoming videos of uh GCP VM. But
this is a good starting point that if
you have a simple web application hosted
on a compute engine, how do you attach
that to a custom domain, your own
domain, right? Let's get started. To get
started, first of all, we'll click on
create instance. You can let the default
reason as B. Let me change the machine
type to N1 N1 standard one.
Now here we need to change one thing. So
since we are just going to host a
container of Apache, we'll be choosing
container optimized OS. So it's a very
lightweight OS and uh it has everything
pre-installed what we need to uh run
containers. So I'm just going to use it.
Click on select.
After that I'll go ahead and click here.
Okay. So as a startup script this
container will be auto deployed. So I'm
there are two ways to do it. Either I
can push the containers to gclio. We'll
do it that do that later. But for now it
will go to docker hub and pull it from
there. No changes here. Just click on
select. So what I'm saying is create a
VM with COS OS and deploy container of
HTTPD over that VM. Okay, come down
click on here. You'll see the external
IP address is for. So I'll click on it.
I'll click a create IP address.
I'll give a name as cloud sprint
sprint external
IP.
I'll just reserve it. So what I'm saying
that I'm attaching a reserve static IP
external IP address so it do not change
when it gets restarted.
That's it. Click on done. No changes.
Click hit create. Now as discussed
earlier it is creating a virtual machine
which has cost operating system and it
will automatically deploy a Apache uh
container for me. Right? That's the
expectation. We what what we also did we
created an external IP address and we
attached that external IP address to VM.
Why? We'll use that later. Meanwhile, it
is being created. Let's come here and
see if we have any IP address created.
Yes, here you can see it. What we
created is created here. Let's copy
this. I'll tell you where we'll use it.
Go back to VM instance. And uh now what
we'll do we'll try to open this and see
if it is giving any response. Okay, it
is giving the response standard response
from Apache. It works. But I want this
behind cloudsprint.in,
right? I don't want to pass this IP or
expose this IP to external world. How
I'll do it? Let's go ahead and check
that out. First of all, I'll go to menu
and uh and network services cloud DNS.
In cloud DNS we'll create a zone
a public zone. So I'll say that it's a
custom domain. DNS name is cloudsprint.in.
cloudsprint.in.
Okay. So I'll say the zone name is
custom domain. DNS name is cloudsprint.in.
cloudsprint.in.
I'll click on create.
So it is saying that custom domain has
been successfully created. Configure
your domain. Okay. Fine. Now I will be
adding two record sets.
First is the IP address. Okay, as a a
record type, I'll be adding the IP address.
address.
Once that is done, I'll be adding one
more is called CNAME.
In the CNAME, I'll add one more entry
So I'll say cloudsprint.in. I'll create
a CNAME entry.
Now these two custom domain uh I have
configured. Now what I need to do I need
to just update the name servers these
four addresses at my where I have booked
my domain. So my domain is with
godaddy.com. I'll come to godaddy.com
and click on domains manage DNS and here
I have to update my name server. It is
using default name server. So let me
Enter my own name space. So I'll say one
then two.
We had four. 1 2 3 4. So I'll go back
and I'll change this to two
to three and to four.
So I updated I entered my own name
servers. I'll click on save. So what it
will do whenever somebody will
okay I'll say uh continue. So what it
will do whenever somebody opens a
domain, this domain name server will
directly send the traffic to uh one of
these name servers which will come to
this DNS and over this DNS we have an A
record of this particular IP address and
this IP address is attached to VM and
this VM has container. So how entering a
URL will take you to container that's
the journey it has to follow. Now let's
go ahead and check if the name space is
updated. So for that I'll open cloud sprint.in.
It's still not updated. It takes some
time. Let's Okay, it's already 10
minutes since I have updated the
records. Let's go ahead and check if it
is uh updated or not. So I'll for that
I'll say ping cloudsprint.in.
Okay. Okay, the IP address which I'm
getting is 3 4125 23 9. So let me
confirm if it's the one. Yes. So it
means it is already name server is
pointing to the right DNS record. Okay.
Right record. Now whenever somebody
tries to open the website, it will
redirect to this uh DNS. Okay. And this
DNS will redirect us to that VM. Now
let's go ahead and try to open the uh website.
website. cloudsprint.in.
Okay, it's the cache. Let me try this in incognito.