I'm stuck with a CORS at S3+Cloudfront+Signed Urls.
My use cases is:
First story (successful):
I have an Amazon S3 bucket with a Cloudfront. Files are accessible by the
DOMAIN1/filelinkI write a simple test JS script to get file from DOMAIN1 and put it at the
DOMAIN2/test.html- I'm able to get file successfully. CORS is fine.
Second case (successful too):
- I restrict Cloud Front distribution by using Signed Url.
- At first I tried is to access a file at DOMAIN1 without Signature. Got an Access denied. It's ok, since request is not signed.
- I've created a signed URL and able to download the file successfully.
Third case (failed)
- I put signed url (from 2nd case) to the
DOMAIN2/test.htmltest script - And always got a
No 'Access-Control-Allow-Origin' headererror.
So Cloudfront is not sending a header in case of restricted distribution.
CORS xml is:
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>http://*</AllowedOrigin>
<AllowedOrigin>https://*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<AllowedMethod>HEAD</AllowedMethod>
<MaxAgeSeconds>10</MaxAgeSeconds>
<AllowedHeader>*</AllowedHeader>
</CORSRule>
It must be some issue in the CloudFront/S3/IAM settings. How I can fix it?