Add domain or sub-domain to google Compute

In this post you will learn how to add a domain and/or a sub-domain to Google Cloud DNS.

8
4640

Long before I switched to VPS, I was a rookie thinking that C panel is the only thing in the whole world capable of doing what I want and need from a hosting environment.
Yes, I was wrong. 80% of its capabilities I never, never ever used. It’s literally just for playing and introducing yourself to the hosting environment, which is great and necessary in the very beginning.

Lets get right to the core:
To add a domain to you VM instance (and website), go to
Network Services > Cloud DNS

2. ..then click on +Create Zone
You will be asked to fill 3 fields.

In the Zone name Just type something like ” mysites domain zone”
DNS name is your domain: yoursite.com
Click “Create”.

Then, add an A record to point your domain to your server’s IP, and
add a CNAME record to point your www.yoursite.com to yoursite.com

To add any sub-domains, just add an A record, write your sub-domain name and point it to your server’s IP.

Do not forget to reserve your domain/server IP, to make it static. The thing is that Google holds the right to change your server’s IP if the system finds it necessary, which probably ain’t gonna happen, but to be sure it is better to reserve the IP.

To do that you have to navigate to VPC network > External IP addresses. From there change (under ‘Type‘) Ephemeral to Static. That’s it.

Cheers

8 COMMENTS

  1. Hi Thanks for the article.

    I did the same thing and able to access my website.I created a sub domain via A record and pointed to same reserved static IP. and also created another virtual directory in IIS.
    But when I browse sub domain it is not pointing to my sub domain virtual directory instead opening default website.

    could you please let me know how to point my sub domain to sub domain virtual directory

    • Hi,
      I would be glad to help you of course, but you need to give me little bit more details.
      I need to know are you using anything like Serverpilot or similar? Is it a wordpress app? is it on nginx or LAMP..? etc

  2. I created a sub domain via A record and pointed to same reserved static IP. But my subdomain is redirect on my domain. I need your help.

    • I don’t know unless you share more info, like: are you running WordPress (how did you install it) and the rest of your DNS zone configuration.

  3. Thank you. I have a question, Adding the A record and pointing to my server static IP. will it actually go to SUB.MyStaticIP ?
    Because I have nginx server setup and configured to handle the subdomain when requested but I’m not sure will the browser respond to SUB.MyDomainName with SUB.MyStaticIP or just MyStaticIP

    • Every time you call your server ip in the browser, your server will respond with the default (main) website.
      There are no sub.staticIP calls – impossible. For example: you cant have “ninja.123.45.67.8”, you can only have 123.45.67.8.
      You need nginx to resolve the subdomain or domain requests. Google DNS creates and points your subdomain to your server, and then the server must be able to tell the difference between subdomain or domain requests.

      If you simply want to use nginx, it is best to let it be handled by one of the best in class control panels.
      You should try Vesta CP, or maybe ISP Config, or similar.

      Managing nginx on your own is hard and time consuming even for professionals.

LEAVE A REPLY

Please enter your comment!
Please enter your name here