gpt4 book ai didi

amazon-web-services - 当源是 S3 存储桶时,AWS CloudFront 返回 http 307

转载 作者:行者123 更新时间:2023-12-03 11:36:50 33 4
gpt4 key购买 nike

我已经用一些文件创建了 s3 存储桶。我使用该 S3 存储桶作为源创建了 CloudFront 分配,并将状态更改为已部署。

当我为任何文件 curl CloudFront 时,我得到:

<Error><Code>TemporaryRedirect</Code><Message>Please re-send this request to the specified temporary endpoint. Continue to use the original request endpoint for future requests.</Message><Bucket>MY-BUCKET</Bucket><Endpoint>MY-BUCKET.s3-eu-west-1.amazonaws.com</Endpoint><RequestId>...</RequestId><HostId>...</HostId></Error>

当我为任何文件 curl 我的 S3 存储桶时,我会得到该文件内容。

我究竟做错了什么?如何强制 cloudfront 缓存文件,以便客户端不需要直接从 S3 获取数据?

最佳答案

Thx Matt Houser 从评论到我的第一篇文章!

当分发尚未完全准备好时,CloudFront 似乎缓存了我对文件的第一个请求(但当时它处于部署状态,所以要小心!)。我请求使缓存中的所有文件失效,这需要几分钟,但在失效完成后,所有文件都使用 CloudFront url 用 http 200 curl 。

在 Michael-sqlbot 发表评论后,问题变得清晰起来:

All buckets have at least two REST endpoint hostnames. In eu-west-1, they are example-bucket.s3-eu-west-1.amazonaws.com and example-bucket.s3.amazonaws.com. The first one will be immediately valid when the bucket is created. The second one -- sometimes referred to as the "global endpoint" -- which is the one CloudFront uses -- will not, unless the bucket is in us-east-1. Over a period of seconds to minutes, variable by location and other factors, it becomes globally accessible as well. Before that, the 307 redirect is returned. Hence, the bucket was not ready.

关于amazon-web-services - 当源是 S3 存储桶时,AWS CloudFront 返回 http 307,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38706424/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com