在AWS CloudFront上启用POST/PUT/DELETE吗? [英] Enabling POST/PUT/DELETE on AWS CloudFront?

查看:89
本文介绍了在AWS CloudFront上启用POST/PUT/DELETE吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在AWS CloudFront中,我在默认缓存行为设置"区域的允许的HTTP方法"中进行设置: GET,HEAD,OPTIONS,PUT,POST,PATCH,DELETE

In AWS CloudFront I set this within: "Allowed HTTP Methods" in the "Default Cache Behavior Settings" area: GET, HEAD, OPTIONS, PUT, POST, PATCH, DELETE

我的CloudFront已链接到AWS S3存储桶.因此,我将AWS S3 CORS配置设置为:

My CloudFront is linked to an AWS S3 bucket. So I set the AWS S3 CORS configuration to:

<?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存储桶策略是:

My current AWS S3 bucket policy is:

{
    "Version": "2008-10-17",
    "Statement": [
        {
            "Sid": "AllowPublicRead",
            "Effect": "Allow",
            "Principal": {
                "AWS": "*"
            },
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::<bucket_name_here>/*"
        }
    ]
}

不幸的是,当通过 curl 运行时,我得到:

Unfortunately when run through curl I get:

$ 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==

推荐答案

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

It may be too late to answer this question. One of the causes of this issue is the Default Root Object . The POST request must be made to the cloudfront root url ("/"). Check the 'Default Root Object' settings in cloudfront. Its value must be empty, and not index.html.

这篇关于在AWS CloudFront上启用POST/PUT/DELETE吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆