S3 POST 请求到 S3,响应为 405 [英] S3 POST request to S3 with response 405

查看:42
本文介绍了S3 POST 请求到 S3,响应为 405的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了将我的存储桶之一用作静态网站托管,我对 S3 进行了以下 CORS 配置:

I have the following CORS configuration for S3 in order to use one of my buckets as a static website hosting:

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

然后我有以下编辑重定向规则:

Then I have the following Edit Redirection Rules:

<RoutingRules>
    <RoutingRule>
    <Condition>
        <KeyPrefixEquals>abc</KeyPrefixEquals>
    </Condition>
    <Redirect>
        <HostName>myec2instance.com</HostName>
    </Redirect>
</RoutingRule>

我想要做的是当 S3 收到到/abc 的 POST 时,将请求和请求正文重定向到我的 ec2 实例.重定向规则工作正常(我能够通过将 POST 切换到 GET 请求来测试这一点),但出于任何原因,当请求是 POST 时,S3 会返回 HTTPResponse 405.任何想法为什么?

What I want to do is when S3 receives a POST to /abc redirects the request and request body to my ec2 instance. The redirection rule is working properly (I was able to test this by switching POST to a GET request) but for any reason S3 is returning HTTPResponse 405 when the request is a POST. Any ideas why?

推荐答案

这与 CORS 无关——它是 S3 本身.S3 网站端点仅配备 GETHEAD.在检查重定向规则之前,应该拒绝任何其他事情.

This isn't CORS related -- it's S3 itself. The S3 website endpoints are only equipped for GET and HEAD. Anything else should be denied before the redirection rules are checked.

网站端点

仅支持对对象的 GET 和 HEAD 请求.

Supports only GET and HEAD requests on objects.

——http://docs.aws.amazon.com/AmazonS3/latest/dev/WebsiteEndpoints.html

这篇关于S3 POST 请求到 S3,响应为 405的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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