7
votes

I'm trying to get my Google domain to connect to my Google Cloud bucket. I have followed all the instructions carefully on this page:

https://cloud.google.com/storage/docs/hosting-static-website

...such as entering the DNS numbers, making the files public, etc. And the domain is verified since it is a Google domain. But no matter what I do, I can't get the domain to serve up the files in the bucket. Any help would be appreciated.

4

4 Answers

11
votes

Create a CNAME alias that points to c.storage.googleapis.com. is where google cloud documentation does not give much information.

Follow this steps. I will take an example of www.mydomain.com as a sample domain.

  1. Goto https://domains.google.com

  2. Select Configure DNS.

  3. Goto Custom Resource Records section at the bottom

  4. Put www.mydomain.com(your domain) in the left input box.

  5. Select CNAME in the drop down. c.storage.googleapis.com as DATA. Hit save. The name would come as www. Dont worry about that.

  6. Goto Storage of google cloud. Create a new bucket. Give the bucket name same as the domain name ie www.mydomain.com here.

  7. Upload the files in the bucket.

  8. Go inside the bucket and give permission to the pages as share publicly (https://cloud.google.com/storage/docs/access-control/making-data-public#buckets).

  9. Goto website configuration(3 dots towards the right) in the bucket list. Give the name of the home page to Main Page. For example index.html. Put the error page in the 404 not found input box. Hit save and you are done.

  10. Try running your website and see if you are able to hit the page.

If you are getting error as DNS not found then there is some issue with CNAME linking.

If you are geting error from the bucket such as permission that means that your DNS is connected to bucket but there are some permission issues with the files.

3
votes

I finally figured it out. I made the bucket with the www prefix, put a CNAME setting that points to the googleapis thing, and then under synthetic records, I put a permanent forward from the root domain to the www domain name using the @ character. Now everything works. Thanks for your help.

2
votes

When doing anything with DNS, it's important to remember that DNS propagation can take an hour or more.

Here are some quick troubleshooting steps:

  1. Were you able to create a bucket named www.mywebsite.com? If so, you have definitely already demonstrated to Google that you own the domain.
  2. Use a DNS tool like dig or any number of lookup websites to verify that the domain 'wwww.mywebsite.com' has a CNAME entry with the value 'c.storage.googleapis.com'. If that's not true, Google will never see requests for your domain.
  3. Verify that your files are publicly visible.
  4. Verify that you configured a main page suffix, so that GCS knows which file to serve if the user goes to "htp://www.mywebsite.com". You can do this by running: gsutil web set -m index.html gs://www.mywebsite.com.
  5. Make sure you're going to http://www.mywebsite.com and not https://www.mywebsite.com. GCS does not directly support HTTPS for custom domain web serving. To do that, you'll want to configure Google Cloud Load Balancing: https://cloud.google.com/compute/docs/load-balancing/http/using-http-lb-with-cloud-storage
  6. Are you trying to set up a root domain, like "mywebsite.com.", and not a subdomain, like "www.mywebsite.com."? You can't do that. Root domains shouldn't have CNAME resource records.
-1
votes

This answer is for any domain (as opposed to just Google Domain).

Please refer to the official documentation for this

When creating the bucket, provide the same that you configured as CNAME. You should see:

To create a bucket named example_cname.example.com you must verify that you're authorized to use that domain name. Follow the link in the 'Name your bucket' step for verification instructions.

You will also have to to confirm your domain.

Once you create the bucket, head over the the 'Overview' section to confirm the URI is correct. e.g. (gs://example_cname.example.com). Note the gs:// prefix.

Noteworthy: From official documentation over here

Note: You can use a CNAME redirect only with HTTP, not with HTTPS. To serve your content through a custom domain over SSL, you can set up a load balancer.

Noteworthy: If using a service account to configure (such as when using Anssible), the request may fail stating it isn't an owner of the domain. Add the service account email at Webmaster Tools. Other IAM setup isn't useful except get and create buckets permissions (e.g. DNS). Search Console setup of the domain doesn't work either.