While attempting to switch our site from http to https links to existing files on AWS are returning the following XML error:

<Error>
  <Code>PermanentRedirect</Code>
  <Message>
    The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.
  </Message>
  <Bucket>bucket.name-private</Bucket>
  <Endpoint>bucket.name-private.s3.amazonaws.com</Endpoint>
  <RequestId>S1O2M3E4R5E6Q7U8E9S0T1I2D</RequestId>
  <HostId>
    SoMeLoNg/StRiNgSoMeLoNgStRiNg+SoMeLoNgStRiNg=
  </HostId>
</Error>

I believe this is because if a bucket has a region set, it needs to have the AWS url contain the region (aka location).
Similar issue: https://github.com/thoughtbot/paperclip/issues/2151

This can be tested on a local machine by adding $https = TRUE; to the top of StorageS3::serviceInstanceServe() to force the url to be formatted to be https.

This can be fixed by changing the url to amazon to include the region/location ie change:

  • s3.amazonaws.com
  • s3-REGION.amazonaws.com

I don't know what the implications are for this change, but I've tested the attached patch on both http and https and have found no issues yet.

Comments

mdolnik created an issue. See original summary.

mdolnik’s picture

Issue summary: View changes
StatusFileSize
new1.5 KB
mdolnik’s picture

Issue summary: View changes