Amazon S3(Simple Storage Service)广泛用于图片、音视频及附件存储。站点流量增长时,难免遇到资源被第三方恶意盗用,增加费用压力。下面为你介绍几种常见的 S3 防盗刷(防盗链)配置方法,保护你的文件安全!
原理:通过检查 HTTP 请求头中的 Referer 字段,仅允许特定来源访问你的资源。
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowGetRequestsReferredByMySite",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::yourbucketname/*",
"Condition": {
"StringLike": {
"aws:Referer": [
"https://yourdomain.com/*",
"https://www.yourdomain.com/*"
]
}
}
},
{
"Sid": "DenyGetRequestsNotReferredByMySite",
"Effect": "Deny",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::yourbucketname/*",
"Condition": {
"StringNotLike": {
"aws:Referer": [
"https://yourdomain.com/*",
"https://www.yourdomain.com/*"
]
}
}
}
]
}
推荐为重要资源上 CDN(如 AWS CloudFront),并为资源访问加上签名限制,有效防止盗刷。
配合 WAF(Web Application Firewall)、API Gateway、Lambda@Edge 实现复杂防护,如限制单一 IP 的访问频率等。
防盗刷需要多层防护。建议结合 Referer 限制、CDN 签名、访问权限配置等方式,并借助 AWS 的监控和自动化工具,最大程度降低风险。如果是重要资源,建议优先使用带签名的 CloudFront URL!
😉 有更多具体需求,欢迎随时咨询!
Alibaba Cloud
Amazon Web Services
Tencent Cloud
Google Cloud
支付金额:
$
0
赠送金额:
$
0
Exclusive for New Users
到账金额:
$
0
支付方式 USDT-TRC20