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
Clic para expandir
Haz clic para explorar el mapa mental interactivo completo
[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.
Okay, we can see clearly it is not
opening. So whenever situation like this
happens, you should know that it is due
to firewall generally it is not getting
response. So with this we confirm that
there's no problem with domain side.
Okay, domain is successfully sending the
request to uh our DNS record. Now let's
go ahead and check what is the
difference. So here also we are pointing
to the right IP address. So we are good
with DNS as well. Now the problem is
from DNS to ingress traffic to this uh
VM that is not being allowed. For that
I'll go to firewall rule. In firewall
rule there's a rule called default allow
HTTP. What it does? It says that all the
traffic should be allowed on port 80.
Okay, port 80. And if it is attached on
a VM, the list should be here. So I
don't see any VM which means this
particular firewall rule is not appended
with the VM which we have created.
That's why ingress traffic is not being
allowed. Okay. To enable it, what I'll
do? I'll copy this target tag. Go to VM.
Click on the instance. Click on click on edit
edit
and directly search search network
tag. Okay. Here I will pass the HTTP
server. Let's see if it has got the
response. Yes, you can see site can be
reached till now. So I'll click on HTTP
server again. Click on save. Once I save it,
it,
you'll again we'll again go ahead and
check at the firewall level that this VM
is showing there or or not. Firewall on
firewall, I'll be taking a very uh
detailed session because that is
something very very important when you
work on Google cloud but for now just
understand it's to allow the ingress
traffic from DNS studio VM. Okay. here.
Now you can see this VMS instance one is
visible. Right? Now let's go back. Yes,
you can see since as soon as we fixed
the firewall rule, it started working.
Right? So this was the task. This is how
you host a container on a VM very very
quickly. And this is how you exposed it
via uh a custom domain. You can see it's
not secure because I have not bought the
SSL certificates that sometime later
I'll cover that as well. But when you
work for a corporate it's uh it is
something you get by default over there.
So you can configure that. But uh for
now this is how you do it on with a
custom domain. That was the idea of the
session. Now since we are done with it I
want to save money. For saving money
first of all what I need to do I need to
delete the VM.
First of all I'll delete the VM. Once I
delete the VM, what it will do? Release
this IP address, static IP address. And
the pricing model of static IP addresses
are if it's not in use, you will be
charged. Once this VM is removed, we'll
go ahead and release that as well.
For that, we need to go to you need to
go to VPC network IP addresses.
We'll click here. Yes, it's used by
none. So, I'll click here. Click on
delete static address. So delete
this is also deleted. Now I need to
delete the custom domain. There's one
thing until these until these two things
are added you cannot delete it. Okay.
You need to remove these record sets
which you have added then only you can
delete a custom do. Yeah. So now you can
delete the DNS zone. Click on delete.
That's how you should clean up your
stuff once you're done with your work.
So I yeah that's that's all. So I hope
this was u this was helpful and you got
the idea that how these all things put
together works right. All right. So that
was all. Now now as I mentioned we have
better ways to do it through uh load
balancers. So when we do manage instance
group I'll be showcasing the same thing
with manage instance group with
different reasons. How do you deploy
enterprise level applications? Multiple
reasons that's and without any external
IP to make it much more secure. For that
subscribe, like. Thank you very much for
watching the video. See you in the next one.
one. [Music]
Haz clic en cualquier texto o marca de tiempo para ir directamente a ese momento del video
Compartir:
La mayoría de las transcripciones están listas en menos de 5 segundos
Copia con un clicMás de 125 idiomasBuscar en el contenidoIr a marcas de tiempo
Pega la URL de YouTube
Ingresa el enlace de cualquier video de YouTube para obtener la transcripción completa
Formulario de extracción de transcripción
La mayoría de las transcripciones están listas en menos de 5 segundos
Instala nuestra extensión para Chrome
Obtén transcripciones al instante sin salir de YouTube. Instala nuestra extensión de Chrome y accede con un clic a la transcripción de cualquier video directamente desde la página de reproducción.