Link GCP Compute Engine with (Sub-)Domain

126 Views Asked by At

I'm looking for a way to access the web server by my domain. Is there a way to get access by add a hostname to my vm or have to use DNS? Please give me short tips, where i have to edit/setup my configuration.

my situation

my web server (apache2) running on a compute engine (name: insatnce-one) in GCP. I'm able to access the website by the external IP address from my instance, so everything works fine.

PS: I owned a domain incl. subdomains (example: instance-one.mydomain.com).

Thank each of you, for helping :)

EDIT: my external IP Adress is dynamic, so where i can setup the DynDNS?

2

There are 2 best solutions below

0
akshay On BEST ANSWER

To give your web server a permanent IP address, reserve a static external IP address and point to it from your DNS registrar (GoDaddy, hostinger).

Steps:

Reserve a static external IP address for your Compute Engine instance.

gcloud compute addresses create ADDRESS_NAME --addresses=IP_ADDRESS \
    [--region=REGION | --global]

Create an A record in your DNS registrar for your subdomain and point it to the reserved external IP address.

More... Cloud DNS Reserve a static external IP address

0
Syed Sajjad Askari On

To link GCP Compute Engine with a (sub-)domain:

  1. Create a DNS record. This tells the internet where to find your web server. You can create a DNS record through your domain registrar or by using a DNS management service like Google Cloud DNS.

  2. Set up dynamic DNS (DDNS). This automatically updates your DNS record when your VM's IP address changes. This is useful if you have a dynamic IP address, which is the case for most Compute Engine VMs. You can set up DDNS with a service like Cloudflare DNS or Google Domains.

  3. Update your VM's hostname. This is the name that your VM will use when it identifies itself to the network. You can update your VM's hostname in the Google Cloud console.

Once you have completed these steps, you should be able to access your web server by its subdomain (e.g., instance-one.mydomain.com).