amazon web services - Custom redirection rules on S3 returns 403 when using CloudFront -
i have custom redirection rule bucket on s3:
<routingrules> <routingrule> <condition> <keyprefixequals/> <httperrorcodereturnedequals>404</httperrorcodereturnedequals> </condition> <redirect> <protocol>https</protocol> <hostname>example2.com</hostname> <replacekeyprefixwith>services/create?key=</replacekeyprefixwith> <httpredirectcode>307</httpredirectcode> </redirect> </routingrule> </routingrules>
and bucket has proper policy:
{ "version": "2008-10-17", "statement": [ { "sid": "publicreadforgetbucketobjects", "effect": "allow", "principal": { "aws": "*" }, "action": "s3:getobject", "resource": "arn:aws:s3:::example.com/*" } ] }
this works fine when access via internal url http://example.com.s3-website-us-east-1.amazonaws.com
, redirects me other server properly.
however, doesn't work cloudfront setup. when try access directly (http://example.com/images/dummy.jpg
), receive 403 accessdenied.
apparently, when using default s3 bucket origin - won't respect redirection rules.
by default, tries use:
example.com.s3.amazonaws.com
, should force custom origin:
example.com.s3-website-us-east-1.amazonaws.com
instead.
once forced it, started work.
Comments
Post a Comment