Google cloud bucket use for static services without having a domain

Viewed 542

I have a static website that I want to use google bucket for it. However, as I do not have a domain I want to directly use the bucket with allUsers permission to view.

In order the users do not see the default folder structures of the bucket I made a load balancer that at least if someone goes to my bucket I directly redirect them to the build/index.html however I get permission error when the bucket is public ( with all of its contents)

I made this setting via IP of the machine that bucket is created on.

enter image description here

But I get the typical 403 error

enter image description here

1 Answers

You don't need to setup advanced host and path rule. The default simple host and path rule option will do.

I found a similar case regarding your question. You can prevent users from listing your entire bucket directory by changing the permission from Storage Object Viewer to Storage Legacy Object Viewer. Since the Storage Object Viewer role contains the permissions for both storage.objects.get andstorage.objects.list, this will include permissions to list the objects in the bucket. For a reference list of the IAM roles that apply to cloud storage, see IAM Roles for Cloud Storage.

Next, you can do a "redirect" by assigning build/index.html as a specialty page. As for the steps, you can follow:

  1. Upload an empty index.html file in the root of your bucket.
  2. Open the bucket settings and click the Edit Website Configuration
  3. Set the newly uploaded index.html as the "Main Page"

You can check the answer of Hao Xu, and the answer of maxime respectively.

Related