# 在位于 URL //s3-bucket/prefix/file.jpeg 的存储中找不到文件

**URL:** <https://meta.discourse.org/t/could-not-find-file-in-the-store-located-at-url-s3-bucket-prefix-file-jpeg/268084>\
**Category:** Self-hosting\
**Tags:** unsupported-install\
**Created:** [2023年六月12日 19:51 UTC](https://meta.discourse.org/t/could-not-find-file-in-the-store-located-at-url-s3-bucket-prefix-file-jpeg/268084 "2023-06-12T19:51:11Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![nodomain](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nodomain/32/303402_2.png) [@nodomain](https://meta.discourse.org/u/nodomain)\
**Post date:** [2023年六月12日 19:51 UTC](https://meta.discourse.org/t/could-not-find-file-in-the-store-located-at-url-s3-bucket-prefix-file-jpeg/268084/1 "2023-06-12T19:51:12Z")

</div>

我目前正在设置 AWS ECS 上的官方 Docker 镜像。  
在 EC2 上运行时，Docker 镜像工作得非常好。

但是，在 ECS 上使用相同的配置启动后，我最终遇到了损坏的头像图片。

相关错误：

```plaintext
在位于 url：//x-dev-xx-xxx-x.s3.dualstack.eu-central-1.amazonaws.com/original/1X/761c151e2d0ebedff3330dc6ec7a27050fef43f9.jpeg 的存储中找不到文件

```

和

```plaintext
无法正确处理劫持的响应：FinalDestination::SSRFDetector::LookupFailedError：FinalDestination：查找失败

```

文件在存储桶中，并且访问权限与 EC2 实例相同。

有人能指出我可以深入挖掘并找到根本原因的地方吗？

谢谢。

---

<div class="post-metadata">

**Author:** ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)\
**Post date:** [2023年六月13日 01:10 UTC](https://meta.discourse.org/t/could-not-find-file-in-the-store-located-at-url-s3-bucket-prefix-file-jpeg/268084/2 "2023-06-13T01:10:18Z")

</div>

> [@nodomain](#):
>
> 我目前正在 AWS ECS 上设置官方 Docker 镜像。

您是否构建了一个包含启动器的镜像并将其推送到仓库？您是否使用与启动器相同的环境变量来启动它？

---

<div class="post-metadata">

**Author:** ![nodomain](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nodomain/32/303402_2.png) [@nodomain](https://meta.discourse.org/u/nodomain)\
**Post date:** [2023年六月13日 04:04 UTC](https://meta.discourse.org/t/could-not-find-file-in-the-store-located-at-url-s3-bucket-prefix-file-jpeg/268084/3 "2023-06-13T04:04:09Z")

</div>

是的。我使用了 `run-cmd` 命令生成的环境变量。到目前为止，我没有发现任何错误。  
不幸的是，我至今还没有找到 Discourse 的 ECS 示例。

---

<div class="post-metadata">

**Author:** ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)\
**Post date:** [2023年六月13日 04:15 UTC](https://meta.discourse.org/t/could-not-find-file-in-the-store-located-at-url-s3-bucket-prefix-file-jpeg/268084/4 "2023-06-13T04:15:19Z")

</div>

你思路是对的，但是迁移展架和上传资源很棘手。我不确定问题可能出在哪里。

---

<div class="post-metadata">

**Author:** ![nodomain](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nodomain/32/303402_2.png) [@nodomain](https://meta.discourse.org/u/nodomain)\
**Post date:** [2023年六月15日 00:36 UTC](https://meta.discourse.org/t/could-not-find-file-in-the-store-located-at-url-s3-bucket-prefix-file-jpeg/268084/5 "2023-06-15T00:36:28Z")

</div>

我找到了根本原因。由于我设置了 Discourse AI 插件，我将一个私有区域添加到了 VPC 中，以便在 VPC 内部提供各种服务。

当 Discourse 在 Docker 容器中的 EC2 实例上运行时，容器会获得一个像 `12-34-56-78-app` 这样的主机名。然而，当在 `awsvpc` 模式下作为 ECS 任务运行时，您无法设置主机名，也无法配置 DNS 搜索域。这导致 ECS 上的 DNS 解析不同，在我的例子中，添加了一个像 xxxx.internal 这样的搜索域。

在深入研究后，我使用 `tcpdump` 发现 Discourse 在 SSRF 检查中尝试解析自己的 FQDN。如果失败，检查就会失败。作为后续错误，对 S3 的调用会以上述错误的错误消息失败。

在我这里，修复方法是将我的 Cloudfront 分配的 FQDN 记录添加到我的私有 DNS 区域。

---

<div class="post-metadata">

**Author:** ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)\
**Post date:** [2023年六月15日 00:57 UTC](https://meta.discourse.org/t/could-not-find-file-in-the-store-located-at-url-s3-bucket-prefix-file-jpeg/268084/6 "2023-06-15T00:57:20Z")

</div>

哇。这真是个不错的调试！这就是为什么这是一个不受支持的安装！其中很多都无法猜测！

---

<div class="post-metadata">

**Author:** ![nodomain](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nodomain/32/303402_2.png) [@nodomain](https://meta.discourse.org/u/nodomain)\
**Post date:** [2023年六月15日 03:29 UTC](https://meta.discourse.org/t/could-not-find-file-in-the-store-located-at-url-s3-bucket-prefix-file-jpeg/268084/7 "2023-06-15T03:29:36Z")

</div>

最终还是老样子：如果它不起作用，那总是 DNS 😂

---

<div class="post-metadata">

**Author:** ![Hyan](https://avatars.discourse-cdn.com/v4/letter/h/5fc32e/32.png) [@Hyan](https://meta.discourse.org/u/Hyan)\
**Post date:** [2023年十月13日 04:32 UTC](https://meta.discourse.org/t/could-not-find-file-in-the-store-located-at-url-s3-bucket-prefix-file-jpeg/268084/8 "2023-10-13T04:32:07Z")

</div>

您好 @nodomain，

我遇到了和您在下面帖子中完全一样的错误。请求用户头像，例如 [https://example.com/user\_avatar/example.com/myself/96/215\_2.png，响应为](https://example.com/user_avatar/example.com/myself/96/215_2.png%EF%BC%8C%E5%93%8D%E5%BA%94%E4%B8%BA) 500。在我的例子中，域名 _[example.com](http://example.com)_ 没有在公共 DNS 中设置，在测试阶段，我在本地的 hosts 文件中伪造了 [example.com](http://example.com)。当域名 [example.com](http://example.com) 在公共 DNS 中设置好后，这个问题还会出现吗？

> [@nodomain](#):
>
> ```plaintext
> Failed to process hijacked response correctly : FinalDestination::SSRFDetector::LookupFailedError : FinalDestination: lookup failed
> 
> ```
