# 如何为您的 Discourse 社区配置 Cloudflare R2

**URL:** <https://meta.discourse.org/t/how-to-configure-cloudflare-r2-for-your-discourse-community/349512>\
**Category:** Self-hosting\
**Tags:** cloudflare, hosting\
**Created:** [2025年一月29日 06:59 UTC](https://meta.discourse.org/t/how-to-configure-cloudflare-r2-for-your-discourse-community/349512 "2025-01-29T06:59:26Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![Eviepayne](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eviepayne/32/352733_2.png) [@Eviepayne](https://meta.discourse.org/u/Eviepayne)\
**Post date:** [2025年二月21日 23:13 UTC](https://meta.discourse.org/t/how-to-configure-cloudflare-r2-for-your-discourse-community/349512/8 "2025-02-21T23:13:30Z")

</div>

为了更新此帖子，我需要包含一些在 Cloudflare 为我工作之前必须解决的陷阱。

* * *

# 1. 区域

* * *

> [@shannon1024](#):
>
> **S3 区域：** 您可以输入任何区域，这对 R2 来说无关紧要。

事实并非如此，我必须使用“auto”或我选择的区域，“auto”更容易，所以请使用“auto”。  
如果您需要知道可以使用哪些选项，请尝试使用任意随机字符串作为您的区域，然后：

> sudo -E -u discourse bundle exec rake s3:upload\_assets

> **如果您使用 nixos**
>
> > sudo discourse-rake s3:upload\_assets

这将输出一个错误，其中包含您的有效选项。

* * *

# 2. API 权限

* * *

> [@shannon1024](#):
>
> - **S3 访问密钥 ID：** 输入 R2 存储桶的 API 密钥 ID。这是创建存储桶 API 令牌时提供的 ID。
> - **秘密访问密钥：** 输入创建授予对存储桶访问权限的 API 令牌时提供的秘密密钥。 **重要提示：** 此秘密密钥仅显示一次，请务必安全备份。

同样重要的是要知道，限制性的 API 令牌不起作用。您必须使用 `Admin Read & Write`  
`Object Read & Write` 不起作用。

---

_[View the full topic](https://meta.discourse.org/t/how-to-configure-cloudflare-r2-for-your-discourse-community/349512)._
