I’m trying to access some webpages available using S3, and it works fine using an url like the following: http://my-crazy-bucket.s3-website-us-east-1.amazonaws.com
Thing is.. I need to hide those page's url behind an javascript written proxy application, using express. I was able to do this before using elastic beanstalk instead of S3. But when I tried migrating those static pages from EB to S3, and accessed it using the proxy url for that given s3 bucket. This resulted in the following error:
404 Not Found
Code: NoSuchBucket
Message: The specified bucket does not exist
BucketName: my-proxy-url.com
RequestId: some stuff...
HostId: some more stuff...
I was hoping to see my-crazy-bucket instead of my-proxy-url.com in the BucketName of this error.
I did configured the CORS as permissive in the bucket configuration like this:
<CORSConfiguration>
<CORSRule>
<AllowedOrigin>https://my-proxy-url.com</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<AllowedHeader>Authorization</AllowedHeader>
</CORSRule>
</CORSConfiguration>
But still the problem persists.
Do you guys think I need any additional S3 configuration or the problem is in my proxy (even though it worked before pointing to the same static pages hosted in the old elastic beanstalk instances)?
Not a CORS issue.
You have to change (rewrite) the HTTP Host: header of the incoming request, inside the proxy, before sending the outbound request, so that S3 understands that the bucket in question is my-crazy-bucket.s3-website-us-east-1.amazonaws.com.
It's not enough just to send the request to S3. It needs to be addressed to the correct bucket, and S3 determines which bucket that is, by looking at the incoming Host: header for a bucket endpoint or a bucket name.
Without seeing your proxying code, I can't be more specific.