AWS S3 设置存储桶外部访问

1. 设置公共访问,将阻止关闭

2. 设置访问权限

3.设置存储桶策略

{
    "Version": "2012-10-17",
    "Id": "Policy",
    "Statement": [
        {
            "Sid": "Stmt",
            "Effect": "Allow",
            "Principal": "*",
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::bucket_name/*"
        }
    ]
}
{
    "Version": "2012-10-17",
    "Id": "Policy",
    "Statement": [
        {
            "Sid": "Stmt",
            "Effect": "Allow",
            "Principal": "*",
            "Action": [
                "s3:GetBucketCORS",
                "s3:PutBucketCORS",
                "s3:GetObject"
            ],
            "Resource": [
                "arn:aws:s3:::bu",
                "arn:aws:s3:::bu/*"
            ],
            "Condition": {
                "StringLike": {
                    "aws:Referer": [
                        "https://www.com/*"
                    ]
                }
            }
        }
    ]
}

4.修改跨域访问

<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
    <AllowedOrigin>*</AllowedOrigin>
    <AllowedMethod>GET</AllowedMethod>
    <AllowedMethod>HEAD</AllowedMethod>
    <AllowedMethod>POST</AllowedMethod>
    <MaxAgeSeconds>3000</MaxAgeSeconds>
    <AllowedHeader>*</AllowedHeader>
</CORSRule>
</CORSConfiguration>

 


版权声明:本文为ccr1001ccr1001原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。