Search code examples
google-cloud-platformgoogle-cloud-storagegoogle-cloud-dnsgoogle-cloud-load-balancer

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


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?


Solution

  • 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