I am trying to have Cloudflare to act as CDN for files hosted on S3, in a way that nobody can access the files directly. For example:
S3 bucket: cdn.mydomain.com.s3.amazonaws.com
CDN (Cloudflare): cdn.mydomain.com
What I want is to be able to access cdn.mydomain.com/file.jpg
(Cloudflare) but not cdn.mydomain.com.s3.amazonaws.com/file.jpg
(S3).
Right now I have a CNAME configured on Cloudflare that points to my bucket, and the following CORS:
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<AllowedHeader>Authorization</AllowedHeader>
</CORSRule>
</CORSConfiguration>
If I try to access any file, via S3 or CDN, I get permission denied. If I make a file public (aka grantee Everyone), I can then access that file via S3 and CDN.
I have tried changing the AllowedOrigin
with *.mydomain.com
, but no luck.