nytimes / gcs-helper

Tool for proxying and mapping HTTP requests to Google Cloud Storage (GCS).
Apache License 2.0
55 stars 20 forks source link

GCS Website Config not working with proxy #108

Open flaviotsf opened 4 years ago

flaviotsf commented 4 years ago

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?

bombsimon commented 4 years ago

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.