# Digital Ocean Spaces/S3 的奇怪行为以及 \`example.com\` 大量重复的 CORS 规则

**URL:** <https://meta.discourse.org/t/strange-behavior-with-digital-ocean-spaces-s3-and-lots-of-duplicated-cors-rules-for-example-com/212361>\
**Category:** Self-hosting\
**Created:** [2021 年12 月 16 日 22:03 UTC](https://meta.discourse.org/t/strange-behavior-with-digital-ocean-spaces-s3-and-lots-of-duplicated-cors-rules-for-example-com/212361 "2021-12-16T22:03:49Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

作者： ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)\
发布日期： [2021 年12 月 16 日 22:03 UTC](https://meta.discourse.org/t/strange-behavior-with-digital-ocean-spaces-s3-and-lots-of-duplicated-cors-rules-for-example-com/212361/1 "2021-12-16T22:03:49Z")

</div>

我最近在引导时遇到了这个错误。我使用的是 SFO3 的 Digital Ocean。

```plaintext
“Tasks: TOP => s3:upload_assets => s3:ensure_cors_rules”, “(See full trace by running
 task with --trace)”, “I, [2021-12-16T21:19:05.748497 #1] INFO -- : Installing CORS rules...”, “Attempting to apply ASSETS S3 CORS ruleset in bucket pfaffmanager.”, “At
tempting to apply BACKUP_DIRECT_UPLOAD S3 CORS ruleset in bucket pfaffmanager.”]

```

有什么可能解释这个错误并且有解决方案吗？

嗯。我查看了设置，发现有很多看起来相同的 CORS 规则。我删除了其中一个，结果它们都被删除了。这是一个暂存服务器，我已经对其进行了无数次（或者可能是几百次？）升级，所以也许这种情况最终会发生在所有使用 Digital Ocean 的人身上，但对大多数人来说，这需要 10 年而不是 8 个月。

删除 CORS 规则后，下一次引导成功了，并且在 spaces bucket 的设置中有 2 条 CORS 规则。但是看——规则似乎是为 `example.com.` 设置的 🤷‍♂️

 ![image](https://global.discourse-cdn.com/meta/original/3X/0/2/022889b1dbe17193633724c660e2b7c482057495.png)

我确信我引导过很多次的 AMS3 中的另一个 bucket 有 3 条与上述相同的规则。都是为 `example.com`。我检查了 `app.yml`，看看我是否在做一些愚蠢的事情（如果我做了，那么我会在很多地方以同样的方式做），但 yml 中没有 `example.com`。

在重建时，我在日志中看到这个：

```plaintext
                                                                                                                                                                         
I, [2021-12-16T21:46:58.038151 #1] INFO -- : > cd /var/www/discourse & sudo -E -u discourse bundle exec rake s3:upload_assets                                          
I, [2021-12-16T21:47:39.039145 #1] INFO -- : Installing CORS rules...                                                                                                   
Attempting to apply ASSETS S3 CORS ruleset in bucket pfaffmanager.                                                                                                       
Attempting to apply BACKUP_DIRECT_UPLOAD S3 CORS ruleset in bucket pfaffmanager.                                                                                         
Assets rules status: rules_applied.                                                 
Backup rules status: rules_applied.                                                                                                                                      
Direct upload rules status: rules_skipped_from_settings.

```

我在 `s3_backup_store.rb` 等代码中查找 `example.com`，但找不到解释。

---

_[View the full topic](https://meta.discourse.org/t/strange-behavior-with-digital-ocean-spaces-s3-and-lots-of-duplicated-cors-rules-for-example-com/212361)._
