为 AWS S3 设置 CORS 配置

迈克尔

为了优化我的服务器使用,我将图像(~500)和渲染HTML文件SEO(~1000)移动到S3存储中,它工作得很好,但是,我担心受到DDoS攻击,最终会花费我很多钱,因为亚马逊对每个GET请求收费

我做了关于如何防止一些调查,发现有一个CORS用于配置选项S3

我试过了,但不幸的是,它似乎不起作用。仍然可以从任何地方访问文件URL

在此处输入图片说明 在此处输入图片说明

我究竟做错了什么?

更新:

还尝试设置存储桶策略:

在此处输入图片说明

约翰·罗滕斯坦

CORS configuration permits cross-domain requests. It is not a method for restricting access to files.

By default, browsers will not allow cross-domain requests. For example, the browser will not allow a page served from example1.com to access content from example2.com. This is done to protect your personal information, such as people trying to open iframes to Facebook to access your personal Facebook content.

If, however, example2.com is willing to permit this cross-domain request, then it can add a Cross Original Resource Sharing (CORS) policy that says that example1.com is permitted to access the content in a cross-domain manner. The web browser will then permit the access.

总之:是您的 Web 浏览器控制 CORS。CORS 策略只是告诉 Web 浏览器允许它。

请参阅:跨域资源共享 (CORS)

被推荐人限制

但是,您的特定要求似乎是您愿意提供来自 Amazon S3 的内容,但前提是该内容出现在特定网页上。例如,仅images.example.com在由 提供的页面请求时才显示图像example.com您可以通过在 Amazon S3 存储桶策略中指定 Referrer来实现此目的

限制对特定 HTTP Referrer 的访问

{
  "Version":"2012-10-17",
  "Id":"http referer policy example",
  "Statement":[
    {
      "Sid":"Allow get requests originating from www.example.com and example.com.",
      "Effect":"Allow",
      "Principal":"*",
      "Action":"s3:GetObject",
      "Resource":"arn:aws:s3:::examplebucket/*",
      "Condition":{
        "StringLike":{"aws:Referer":["http://www.example.com/*","http://example.com/*"]}
      }
    }
  ]
}

伪造推荐人相对容易,但这通常应该为您提供所需的信息。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

如何配置无服务器S3存储桶资源以使用CORS AllowOrigin设置为其功能的http端点

AWS S3 Bucket CORS配置未正确保存

AWS S3 存储桶:CORS 配置问题(XML 与 JSON)

为Amazon S3编写IAM策略和CORS配置

添加 AWS S3 设置后,Cors 不起作用。反应

如何使用 OpenAPI 为 AWS API Gateway 配置 CORS?

CORS,S3和CloudFront配置

S3的AWS Boto3 EMR软件设置配置

如何将AWS S3与AWS SNS设置为上载事件?

配置Spring为CORS

如何使用 AWS SDK V2 为 Amazon S3 配置终端节点?

如何使用匿名用户将AWS CLI配置为s3 cp

在AWS S3上为静态网站配置环境变量

使用Terraform为Django静态文件配置AWS S3存储桶

在 Laravel 中上传后将 aws s3 文件权限设置为公开

AWS S3:将“禁止所有公共访问”设置为关闭有风险吗?

使用AWS Java SDK为现有S3对象设置Expires标头

为Presto和AWS S3设置独立的Hive Metastore服务

如何使用 AWS S3 C++ SDK 将签名设置为 v2

资源空间DAM系统-将外部存储设置为AWS S3

如何在 Heroku 上为 AWS S3 正确设置签名的 url 上传?

为 AWS Storage Gateway 卷网关配置 ISCSI 超时设置

基本的AWS S3 PHP设置

s3中的CORS配置:未知字段AllowedHeaders

不接受 S3 存儲桶 CORS 配置

无法使用CORS配置访问S3资源

将AWS Lambda函数配置为s3通知处理程序时如何给出错误响应

AWS Cloudformation | 将Lambda配置为在S3存储桶中使用最新版本的代码

Amazon S3,无法设置CORS策略