Reputation: 484
I've successfully created a static website hosted on Google Cloud Storage.
The bucket name is like: www.example.com
and my CNAME record for www points to c.storage.googleapis.com
I've verified both the www and root domain with Google Webmaster Tools.
On Google Webmaster Tools I have the www set as the primary domain (I have no idea if that's relevant, but saw a reference to it on another post here) and it's important that I serve the site from the www subdomain and not the root.
I can reach www.example.com fine,but no matter what I try with my root domain I only get the <NoSuchBucket>
error.
Point of information: My DNS is managed by Cloudflare. When I use Github pages to host static sites I typically point the root to the www with a CNAME record (and no A record at all because Cloudflare allows CNAME flattening), but that does not work here.
I've tried pointing my root domain to the www with a CNAME record and tried pointing it to c.storage.googleapis.com.
The Cloud Storage website configuration documentation for Step 2 says: "For example, for example.com, the CNAME record contains the following information: www CNAME c.storage.googleapis.com
" but makes no mention of pointing the root domain, yet this must be a common requirement.
I realize I could create an additional bucket with the root domain and point it to the www in http, but it seems as though there should be a way to do this with DNS records.
Upvotes: 22
Views: 8912
Reputation: 3245
This solution another another stack exchange site worked for me
1) Use a CNAME record to set your www.example.com to forward to the true hostname.
2) To configure the naked domain, add a "Synthetic Record", and set up a "Subdomain Forward." In the subdomain text box, enter the @ sign and nothing else.
3) Select option to 'Forward path'. That should do exactly what you want.
Upvotes: 0
Reputation: 49
my solution is: - I created a static website hosted on Google Cloud Storage, with bucket name like: www.mydomain.hu - Added a CNAME record at my DNS provider for www which points to c.storage.googleapis.com - Created a .htaccess file with he following content and uploaded to the root directory of mydomain.hu/
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^mydomain\.hu
RewriteRule ^(.*)$ http://www.mydomain.hu/$1 [R=permanent,L]
If you already have an .htaccess file, insert these four line of code to the beginning of the file.
Upvotes: 1
Reputation: 10701
You could not access your bucket using the url that is different with your domain / subdomains. Evenso when you want to access using the url of your root domain http://yourdomain.com/
to your bucket gs://www.yourdomain.com
or the other way around.
So here you must choose either use your bucket named as your root gs://yourdomain.com
or your bucket named gs://www.yourdomain.com
, if you choose the bucket of www
using your http://www.yourdomain.com/
then its fine as it explained on the documentation.
But if you prefer to use the url of your root domain http://yourdomain.com/
to access your bucket gs://yourdomain.com
, here you need to set the @ record of the domain as an ALIAS/ANAME that act as the same as when CNAME a subdomain when it points to c.storage.googleapis.com
You might find that pointing CNAME of a root domain via @ Record are not supported on your domain providers. To get out from this you can consider to point your NAME SERVERS to a DNS provider who support the ALIAS or ANAME. Please refer to this answer for more detail.
You can try on Google Cloud Storage (GCS), set a Custom NameServers for yourdomain.com and set its @ DNS Record as an alias to c.storage.googleapis.com
. Serve your bucket as public-read and named the same as its TLD (gs://yourdomain.com
). You may find that it works just fine.
Upvotes: 4
Reputation: 3527
There is nothing you can do on Google Storage side to point example.com root domain to www.example.com bucket. The only option is redirecting/forwarding example.com to www.example.com on your DNS provider:
Check these links for forwarding on the Cloudflare:
https://blog.cloudflare.com/introducing-pagerules-url-forwarding/
Upvotes: 6