I've got some GIFs on S3. They are all public. Here is a sample one
I'd like to proxy them through my Go app so the user always sees my custom domain instead of the S3 domain.
The format is simply spolytics.com/{username}/matches/{uuid}/moves/{uuid}.gif
. However, as you can see when you click on the second link, it does not work as expected. I get the error
<Error>
<Code>NoSuchKey</Code>
<Message>The specified key does not exist.</Message>
<Key>
spolytics.com/moves/2bfc1ab0-5bda-4121-a3ea-b34c4fc01260/27e7b9d9-ff09-475f-885a-6b097a466174.gif
</Key>
<RequestId>04A5AD2E108B3B78</RequestId>
<HostId>oNgfLfa4vl3Lb/TWrqgFlGDIXRr2bL6bduhSLKKQF+5w5H82GpnXnXrW3oWY4tVKsnYmiUvx7fI=</HostId>
</Error>
It works when I run the app on my local machine under localhost
. So the keys are definitely right.
Here is my Go proxy code
func(w http.ResponseWriter, r *http.Request) {
uuid := "..."
id := "..."
rawURL := fmt.Sprintf("https://s3.amazonaws.com/spolytics.com/moves/%s/%s.gif", uuid, id)
parsedURL, err := url.Parse(rawURL)
if err != nil {
...
}
director := func(request *http.Request) {
request.URL = parsedURL
}
proxy := &httputil.ReverseProxy{
Director: director,
}
proxy.ServeHTTP(w, r)
}
Any ideas? Especially why it does not work in production?