【发布时间】: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.htmlis not bucket + file in this error -- 那是 just 文件,其路径 inside 存储桶。 Nginx 不会从匹配的location中删除第一个前缀。需要编写您的配置以剥离它。您很困惑,因为它恰好与您的存储桶名称相同。
标签: amazon-web-services nginx amazon-s3