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>
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?
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.
Website Endpoint
Supports only GET and HEAD requests on objects.
— http://docs.aws.amazon.com/AmazonS3/latest/dev/WebsiteEndpoints.html
If you want to use POST
request to S3
, you need to use root object in your browser by creating POSTPolicy
to get S3 authentication
you can refer Browser-Based Upload using HTTP POST
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With