Cloudflare CDN for Google Cloud Storage Bucket - google-cloud-storage

I have a custom domain (cdnexample.com) and a Firebase Google Cloud Storage Bucket (examplefiles.appspot.com).
I want to configure cdnexample.com domain in Cloudflare CDN to source from GCS bucket (examplefiles.appspot.com).
For example, given a GCS File: https://storage.googleapis.com/examplefiles.appspot.com/image1.jpg I want to get the Cloudflare CDN File working: https://cdnexample.com/image1.jpg
The problem is that I cannot change the GCS bucket name (examplefiles.appspot.com) to match my Cloudflare domain name (cdnexample.com). All the solutions I came across below require the GCS bucket name to match Cloudflare domain name and use CNAME configuration with c.storage.googleapis.com.
I have read through the following relevant articles:
https://cloud.google.com/storage/docs/request-endpoints
https://devopsdirective.com/posts/2020/10/gcs-cloudflare-hosting/
https://community.cloudflare.com/t/using-cloudflare-cdn-https-with-google-cloud-storage/15602
How to cache google cloud storage (GCS) with cloudflare?
Using Cloudflare CDN + HTTPS with Google Cloud Storage
Use CloudFlare to CDN a Google Cloud Storage Bucket
https://medium.com/#pablo.delvalle.cr/cloudflare-and-google-cloud-for-hosting-a-static-site-fd2e1a97aa9b
Does anyone have an idea of how to make the Cloudflare CDN work in this case?

In this case you can set up a load balancer with backend bucket which will connect your storage bucket and can be accessed with an IP address, later you point the IP address in your custom domain. you can find the below information about adding a backend bucket here

Related

google cloud CDN always serve my static file through only 1 IP

I have my google bucket connect with a load balancer and CDN enabled in google cloud, but I really don't get how google CDN working for static file, checking in the log viewer i can see the "statusDetails: response_from_cache" and "cacheHit: true" so i can say that the CDN is working properly.
Trying to issue a request for the image in my google CDN bucket from a computer located in Europe, the file return from the frontend IP address of my load balancer. Also the same IP address served my image if i make the request from a computer located in Asia.
So the same IP address was used for serving my static image ignore the location where the request coming from, checking the log viewer again, i can see that both of the request has claimed to go through google CDN, again google log viewer tell me that CDN working properly.
i think that the CDN should serve the file from the nearest server to the end-users, what is the point for using google CDN if the file always served from only 1 single IP address for all user over the world?
I have a free account of cloudflare, once i configure my DNS, the image file go through cloudflare network and if i do the test as above, i will see my static image file returned from multiple IP address which is nearest to my end-users.
Could somebody help me to understand what is the purpose for using google CDN in this case ? did i miss something in the configuration process for google CDN?
Thanks a lot in advance.
Google Cloud CDN uses Google's global edge network to serve content
closer to users and it leverages Google Cloud global external HTTP(S)
load balancers to provide routing, health checking, and Anycast IP
support. The HTTP(S) load balancing configuration specifies the
frontend IP addresses and ports on which Cloud CDN receives requests
and the backends that originate responses to those requests.
Google CDN has a special feature of ‘single anycast IP for the whole
network’ letting all contents served through the load balancer
frontend IP resulting in low latency. So rather than having one load
balancer per region, you can simplify your architecture and have
every instance behind a single global load balancer. Also it has a
feature of HTTP/2 which supports the latest HTTP protocol for faster
performance. For additional information, you can check here.
Cloud CDN reduces latency by serving assets directly at Google's
network edge. To know more about the caching using Cloud CDN, refer
to this caching-overview docs.

Google Cloud Storage files access policy based on IP Address

Is there any way to limit access of all files in a bucket in Google Cloud Storage based on the client IP address?
I have a file stored there, which should be access only by specific IP address. How to do this?
No, there is not currently a way to do this.

Are static sites hosted on google cloud storage accessable through https?

According to this post from 2014, https is not available to static sites on google cloud engine: https://stackoverflow.com/a/22767544/46799
Is this still the case? If so, are there any plans add this functionality?
My site is hosted on GCS and I have a cname entry which maps my url to a bucket on GCS. I need to start providing access to the site through https now, am I out of luck?
This is still the case, sorry. You can access GCS via HTTPS, but not via CNAME redirects.

Use CloudFlare to CDN a Google Cloud Storage Bucket

I've heard many good things about Cloudflare, and they have an excellent CDN product that features functionality not found on competitors (HTTP2, IPv6 etc).
I have files in a Google Cloud Storage bucket.
How to set these files as the origin for a Cloudflare CDN?
(The Cloudflare control panel seems to just want a website on a root domain...?)
Maybe a bit late, but I put my answer just in case it is useful for someone else looking to do the same thing.
I have a bucket in Google Cloud Storage behind CloudFlare. You just need to follow the instructions here:
https://cloud.google.com/storage/docs/website-configuration
In CloudFlare you will need to manage your root domain, but then you can create a subdomain just for your bucket in Google Cloud Storage (don't forget to enable CloudFlare features on that subdomain). I think that's the way CloudFlare works, managing your root domain and I don't think you can avoid it.
If you need specific settings for the subdomain used for your bucket, you can use page rules in CloudFlare. For example, I had to use them because Google Cloud Storage does not support SSL but my pages using those static files were on SSL, so I had specific settings for that subdomain to use flexible SSL.

redirect root domain name to amazon s3

My domain is rather long. I need to use it without www.
All the info I find on the net is about cnames.
How do I redirect the whole domain to an amazon s3 bucket, not only a subdomain?
Amazon recently announced support for root domain hosting via S3. The instructions for setting this up can be found here. Note that you will have to setup two buckets to accomplish this, and that you will have to use Route 53 for your DNS hosting.
Try wwwizer
What you need to do is to create a cname www pointing to your s3 bucket url (bucket name will need to match) and then create an A record to the ip given by wwwizer.
Another way is to use a url redirecting service or use a free web host (like godaddy's ad supported hosting) and on the index file issue a redirect to www.yourdomain.com.
There might be other solutions that rely on finding out the ips of the amazon s3 front end servers but they are error prone.