Amazon S3 存储桶返回 403 Forbidden [英] Amazon S3 bucket returning 403 Forbidden

查看:102
本文介绍了Amazon S3 存储桶返回 403 Forbidden的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近继承了一个使用 S3 存储资产的 Rails 应用程序.我已将所有资产转移到我的 S3 存储桶中,没有出现任何问题.但是,当我更改应用程序以指向新存储桶时,我会收到 403 禁止状态.

I've recently inherited a Rails app that uses S3 for storage of assets. I have transferred all assets to my S3 bucket with no issues. However, when I alter the app to point to the new bucket I get 403 Forbidden Status.

我的 S3 存储桶设置如下:

My S3 bucket is set up with the following settings:

权限

每个人都可以列出

存储桶政策

{
 "Version": "2012-10-17",
 "Statement": [
    {
        "Sid": "PublicReadGetObject",
        "Effect": "Allow",
        "Principal": "*",
        "Action": "s3:GetObject",
        "Resource": "arn:aws:s3:::bucketname/*"
    }
 ]
}

CORS 配置

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

静态虚拟主机

已启用.

我还能做些什么来让公众接触到这些资产?

What else can I do to allow the public to reach these assets?

推荐答案

问题是转移是根据 这个线程,这本身不是问题.问题来自之前的开发人员在传输之前没有更改文件的权限.这意味着我无法管理任何文件,即使它们在我的存储桶中.

The issue is that the transfer was done according to this thread, which by itself is not an issue. The issue came from the previous developer not changing permissions on the files before transferring. This meant I could not manage any of the files, even though they were in my bucket.

问题已通过从以前的存储桶中干净地重新下载文件、删除旧的幻影文件、重新上传新文件并将其权限设置为允许公开读取文件来解决.

Issue was solved by re-downloading the files cleanly from the previous bucket, deleting the old phantom files, re-uploading the fresh files and setting their permissions to allow public reading of the files.

这篇关于Amazon S3 存储桶返回 403 Forbidden的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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