gpt4 book ai didi

amazon-web-services - 在AWS CloudFront上启用POST/PUT/DELETE吗?

转载 作者:行者123 更新时间:2023-12-04 04:25:20 26 4
gpt4 key购买 nike

在AWS CloudFront中,我在“默认缓存行为设置”区域的“允许的HTTP方法”内进行设置:GET, HEAD, OPTIONS, PUT, POST, PATCH, DELETE
我的CloudFront已链接到AWS S3存储桶。因此,我将AWS S3 CORS配置设置为:

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

我当前的AWS S3存储桶策略是:
{
"Version": "2008-10-17",
"Statement": [
{
"Sid": "AllowPublicRead",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::<bucket_name_here>/*"
}
]
}

不幸的是,当通过 curl运行时,我得到:
$ curl -I -s -X POST -H "Origin: www.example.com" [hash_here].cloudfront.net
HTTP/1.1 405 Method Not Allowed
Content-Type: application/xml
Transfer-Encoding: chunked
Connection: keep-alive
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, PUT, POST, DELETE, HEAD
Access-Control-Max-Age: 3000
Vary: Origin, Access-Control-Request-Headers, Access-Control-Request-Method
Allow: GET, DELETE, HEAD, PUT
Date: Sun, 01 Mar 2015 14:12:26 GMT
Server: AmazonS3
X-Cache: Error from cloudfront
Via: 1.1 5896eef8502a96757950c7d389f2015c.cloudfront.net (CloudFront)
X-Amz-Cf-Id: uBK_gStEvSTWypvU8_YYjtfjC2UzdR3Ff_cDLitMaeUBNZ9AgrSkJg==

最佳答案

回答这个问题可能为时已晚。导致此问题的原因之一是默认根对象
POST请求必须发送到 cloudfront根URL(“/”)。检查cloudfront中的“默认根对象”设置。它的值必须是,而而不是index.html

关于amazon-web-services - 在AWS CloudFront上启用POST/PUT/DELETE吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28909827/

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