2

We have a specific situation where we want to serve static websites from GCS (via loadbalancer w G CDN) and we would strongly prefer to NOT use domain naming for the buckets.

The reason why we do NOT want this is the domain verification process which is very user unfriendly and extra steps for our users to do (I think we should be able to automate this process fairly extensive but that is again a ton of extra dev work which I'm trying to circumvent).

I've tried

gsutil web set -m index.html gs://{bucket-name}

And I set mike.adhero.io A record to the IP of the loadbalancer. But it still shows xml style missing error. mike.adhero.io/index.html works as expected

Is there anyway to fix this?

StevenFlecha
  • 61
  • 1
  • 8

2 Answers2

2

Is it possible to set index file for GCS buckets without domain naming?

No. The reason is that this would break the API behavior for normal bucket access (API requests).

The MainPageSuffix and NotFoundPage website configurations are only used for requests that come to Cloud Storage thru the CNAME endpoint or Cloud Load Balancing. For example, a request to www.example.com shows the index page, but an equivalent request to storage.googleapis.com/www.example.com does not.

Thus, API behavior for requests to Cloud Storage domains, such as storage.googleapis.com/www.example.com, is preserved. For example, you can continue to list objects in the www.example.com bucket as you would for any other bucket. In the case of the www.example.com bucket, the object listing you receive includes 404.html and index.html.

This is documented in the following Google document:

Static Website API Behaviour

John Hanley
  • 74,467
  • 6
  • 95
  • 159
  • "The MainPageSuffix and NotFoundPage website configurations are only used for requests that come to Cloud Storage thru the CNAME endpoint or Cloud Load Balancing." >> " I set mike.adhero.io A record to the IP of the loadbalancer" I am using load balancing.. I understand storage.googleapis.com/www.example.com doesn't work and understand that, I was hoping it would work via the load balancer but it seems it doesn't (at least not without a domain named bucket) – StevenFlecha Jul 22 '19 at 06:44
  • I am not sure what you are trying to say. The Google Load Balancer does not implement website configurations in front of Cloud Storage. That is managed by Cloud Storage. – John Hanley Jul 22 '19 at 06:48
  • you said "thru the CNAME endpoint or Cloud Load Balancing.". so I understood that GCS would understand it has to act as 'website service' if traffic is routed via load balancer OR a CNAME.. just always but what I understand now it is still dependent on the bucket name being a domain. So in reality there's no other option for us other then name buckets as domains and write code to automize the verification process. Thanks. – StevenFlecha Jul 24 '19 at 06:50
0


No, it is not possible, as John Hanley mentioned. When you configure a bucket without domain naming this can be considered as a storage space over the cloud and you need to specify the path. You could think about this as a hard drive and a folder, that is why only works properly when you specify the path and the name of the file "mike.adhero.io/index.html" . Once you configure a bucket with the domain name the API recognize you want to use a "Website service" instead of "Storage bucket service".

In my understanding you are trying to use a website service with the storage bucket service configuration, by design and target this is not possible/viable. Please correct me if I'm wrong.

Also as John mentioned, this options needs to be configured at Cloud Storage (when you specify the domain name), since the Load Balancer is only serving as the access point and load distribution for the backend services configured.

Regarding the domain verification process [0], yes initially can be a little bit difficult, once you did the process once or twice can be really easy. I'm sharing with you a couple of videos, first about the web search console [1] and the second to add a TXT record to CLOUD DNS [2], considering that your registrar could be Google Cloud DNS. You can note that the process is the same, you only have to consider the difference in the process of each registrar.

Hope this information helps
Have a nice day!


[0] https://cloud.google.com/storage/docs/domain-name-verification
[1] https://www.youtube.com/watch?v=VRCmKkzeeMI
[2] https://www.youtube.com/watch?v=ixIHDdHeInU