Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Unable to map naked domain (non www) to Google Cloud Storage bucket

 

Good day,

I am trying to host a static site on G Cloud Storage. I followed the documentation here https://cloud.google.com/storage/docs/hosting-static-website and all was successful.
I purchased a domain from namecheap volunux.com and I named my bucket during creation as www.volunux.com after verifying the ownership in Search Console. I wasn't satisfied with the "Not secure" thingy, so I wanted HTTPS, I should have used Load balancer but I was looking for something cheap at the moment.
So I opted for Cloudflare to get me a free SSL and all was fine but here is the problem.
My site works at
www.volunux.com
https://www.volunux.com

but never works when it is:
volunux.com
http://volunux.com
https://volunux.com

For close to 24 hours since yesterday, I have been searching for solution to this problem all over the internet.
1. Some suggested and said, one have to create two bucket in GCS to serve both www and non-www.
2. Some, one have to create another bucket and in the web configuration, set the MainPageSuffix as https://www.volunux.com so that redirect will be perform.
3. Some, one have to create a cname record to c.storage.googleapis.com which I did but didn't work.
4. Some, one have to create an A record to set the IP to my hosting provider, I assume GCP but it didn't work either.
5. Some, I have to create a page rule and redirect all request from volunux.com with or without protocol to https://www.volunux.com

I think #1 would have worked but I have to maintained two separate buckets for one thing and #2, I don't know if it is standard practice but from #3 to #5.
All efforts prove abortive. I have read through threads on Stackoverflow, CloudFlare community, personal blogs, all didn't work out for me.
I have performed a URL Rewrites, 301 redirects from volunux.com/* to https://www.volunux.com/$1 but all efforts prove abortive based on the solutions I have found on the internet,
I am confused at this stage because I don't know what to do. I am thinking of moving back to Github Pages using Jekyll or even to AWS S3 but I don't want to do that just yet.

Somebody please help. Attached are the screenshot of configurations.

five.pngfour.pngone.pngthree.pngtwo.png

0 11 2,240
11 REPLIES 11

So lots of machinery here that might be tricky to explain in a reply.

www.volunux.com is working because you have correctly setup in Cloudflare DNS the configuration to proxy through to Google Cloud Storage and the storage bucket name is www.volunux.com.

However the "naked" or "apex" of volunux.com is not working for two reasons I believe:

1) While you have correctly configured a redirect in Cloudflare, you have pointed Cloudflare DNS to proxy to Google Cloud Storage, but as per point 2, that won't work.

2) Your bucket name is 'www.volunux.com', so Google Cloud Storage only knows about the 'www', not the naked domain.

Instead you need to instruct Cloudflare to respond directly to the requests to volunux.com and then it can do the redirect and you do this by removing the CNAME and instead putting an A or AAAA record towards Cloudflare itself.  According to the documentation here: https://developers.cloudflare.com/pages/how-to/www-redirect/

You need to change the DNS configuration in Cloudflare for volunux.com to:

"either be an A record with the 192.0.2.1 value or an AAAA record with the 100:: value."

This will fix point 1 because you are passing the requests to Cloudflare not Google Cloud Storage and point 2 therefore is no longer relevant because Google Cloud Storage only needs to know about www.volunux.com which it does.

Give that a try and let me know how you get on.  Hope that helps.

I have two CNAME record in the screenshot, am I going to delete the CNAME with the name www. or the one with the name volunux.com.

By the way, I just deleted the CNAME in the first row which is volunux.com and add another record with AAAA with volunux.com as the name and 100:: as the content, still it didn't work.

I contacted NameCheap, they mentioned something like DNS propagation issue and some people I asked to help me try the domain without www using naked domain and both http:// and https:// without www. said it work but it doesn't work with the naked domain on my own computer but works perfectly on my two tablet devices. I am confused.

Have you tried it in your side?

 

six.png

You will likely need the A record as well....AAAA is IPv6.  Add the A record, then on your client machine do a lookup from the command prompt with "nslookup volunux.com" and verify it comes back with the correct IP.   

I just did as you said but I can't interpret what I got from CMD and which IP address to expect and which is correct.

I am uploading another attachment displaying my CF dashboard with a section bordered with  black solid lines, I don't know whether the value should be www. or volunux but you can see that I included volunux and not www., However, this doesn't work still.

I want to remind you that some people I asked to help me check told me the naked domain works including using both http or https:// and it works perfectly on my two tablet devices.

What about the page rule for the domain I included previously, do you think there might be conflict due to this configuration?

This is getting me really confused but I am hoping to get it work.

 

eight.pngseven.png

Actually the nslookup wouldn't help as Cloudflare will be responding with their caching IPs in any case - so ignore me on that one.  

However for me I can see that it is working now, if I go to either http or https to either volunux.com or www.volunux.com, all combinations send me to https://www.volunux.com, which I think is what you're after?

That is what I want, you have an idea why this doesn't work on my personal PC but works on other devices like my two tablets? 

It *might* be DNS cache related on your PC, if you close all browsers, open a command prompt and type "ipconfig /flushdns", then try again maybe?

Just following up to see if you got this resolved?

I performed the ipconfig /flushdns, it didn't make any difference as it didn't work. Different site tools, crawler tools, PageSpeed Insight all tested the site fine with all http protocols with or without www and its fine. I asked relatives to help me try it, it works fine but for my computer, it never works if it is a naked domain.

Thank you for the help once more. 

Happy to try and help - albeit this is perhaps less a Google Cloud issue now 🙂

On your local machine, what behaviour do you see now? Just to be clear.

I agree with you it is less a GC issue now, I want to thank you for your time and inputs. I will keep looking for inputs like yours and all over the internet and maybe fix it some time.