gcs-helper icon indicating copy to clipboard operation
gcs-helper copied to clipboard

GCS Website Config not working with proxy

Open flaviotsf opened this issue 4 years ago • 1 comments

I have a private GCS bucket that is only accessible to staff members - we do that using the GCS-Helper proxy that is mapped to an internal hostname (GCS Proxy deployed to K8s).

Everything works great for the most part - one thing that does not is that even though I've set the GCS web config via: gsutil web set -m index.html -e index.html gs://www.example.com

Requests to a folder like "/a" do not forward requests to "/a/index.html" and I just get a:

<Error>
<Code>NoSuchKey</Code>
<Message>The specified key does not exist.</Message>
<Details>No such object: example.com/a</Details>
</Error>

Has anyone figured out how to get GCS-Helper working with default documents?

flaviotsf avatar Jul 29 '20 16:07 flaviotsf

I'm interested in this as well. Seems pretty easy to fix and I can provide a PR but the authors doesn't seem to maintain this repository anymore so I won't spend time on this right now.

This is how you get what main page suffix and not found page is set to:

bucketAttr, _ := client.Bucket(c.BucketName).Attrs(context.Background())

fmt.Println(bucketAttr.Website.MainPageSuffix)
fmt.Println(bucketAttr.Website.NotFoundPage)

If the given r.URL.Path 404s, we should try filepath.Join(r.URL.Path, bucketAttr.Website.MainPageSuffix). Might need some tweaking to support both trailing slashes and not.

bombsimon avatar Oct 16 '20 10:10 bombsimon