1

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 Answers1

1

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.

RJC
  • 1,224
  • 2
  • 12
  • Thanks but number 2 and 3 does not work. Still if I go to my bucket it shows access denied until I add /index.html at the end of the url – user3201492 Sep 22 '21 at 12:18
  • Hi @user3201492, I see your comment but you've already accepted the answer, just wanted to ask if you're okay with it? Can you please clarify? – RJC Sep 23 '21 at 03:53
  • Hello! still I have problem that I need to set full URL with index.html but anyhow the point related to Storage Legacy Object Viewer was very important so that is why I accepted it as an answer ( 80% of the solution ) – user3201492 Sep 27 '21 at 06:43
  • @user3201492, can you clarify if there's a conflict in your load balancer? Also, did you edit your host and path rule prior to the second part of my answer? – RJC Sep 27 '21 at 08:36
  • I do not have any load balancer indeed. Regarding to the host I actually want to use Cloud Storage to host my static website that is built by React. So I am not sure what do you mean by edit your host then :) – user3201492 Sep 27 '21 at 10:23
  • My impression is that in order the redirect , 404 works the bucket should have a domain name – user3201492 Sep 28 '21 at 07:46