【问题标题】:AWS::S3::NoSuchKey The specified key does not existAWS::S3::NoSuchKey 指定的键不存在
【发布时间】:2022-01-11 22:01:15
【问题描述】:

我正在尝试从 S3 (mydomain.com/frontend-beta) 提供部分网站服务。

我创建了名为 frontend-beta 的存储桶,并启用了具有所有必要权限的静态 Web 托管。也可以毫无错误地访问http://frontend-beta.s3-website-us-east-1.amazonaws.com

当我从提供主网站 (mydomain.com) 的位置更新 nginx 配置并尝试访问 mydomain.com/frontend-beta 时,出现以下错误

404 Not Found
Code: NoSuchKey
Message: The specified key does not exist.
Key: frontend-beta/index.html
RequestId: 6A36E8E8DF29FBCC
HostId: SW2qCgYnhwHtXcDtD8saTIBV6YuExZ8dSZzZPedAYtagyVTq3O00BHAXAotknuF4rRUDJ1xeQYo=

实际上存储桶/文件确实存在 (frontend-beta/index.html),但不知道为什么它无法访问它。

这是我的 nginx 配置

http {
      upstream frontend-beta {
          server frontend-beta.s3-website-us-east-1.amazonaws.com;
      }
}
server {
        .
        .
        .

        location /frontend-beta/ {
           proxy_pass http://frontend-beta;
    }

}

有人知道我在这里缺少什么吗?

【问题讨论】:

  • Key: frontend-beta/index.html is not bucket + file in this error -- 那是 just 文件,其路径 inside 存储桶。 Nginx 不会从匹配的location 中删除第一个前缀。需要编写您的配置以剥离它。您很困惑,因为它恰好与您的存储桶名称相同。

标签: amazon-web-services nginx amazon-s3


【解决方案1】:

查看日志文件,您的密钥是错误的,所以可能有些重定向到 index.html:

Key: frontend-beta/index.html

您的密钥应与 S3 中的对象名称匹配

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-01
    • 2016-12-23
    • 1970-01-01
    • 2015-12-21
    • 1970-01-01
    相关资源
    最近更新 更多