# S3, Assets & CDN Error

**URL:** https://meta.discourse.org/t/s3-assets-cdn-error/272504
**Category:** Self-hosting
**Tags:** cdn, s3
**Created:** [July 22, 2023, 12:00pm UTC](https://meta.discourse.org/t/s3-assets-cdn-error/272504 "2023-07-22T12:00:49Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![LimitlessGreen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/limitlessgreen/32/235212_2.png) [@LimitlessGreen](https://meta.discourse.org/u/LimitlessGreen)
#### Post date: [July 22, 2023, 12:00pm UTC](https://meta.discourse.org/t/s3-assets-cdn-error/272504/1 "2023-07-22T12:00:50Z")

</div>

Hi, I’m facing a strange issue, regarding to: S3 (DigitalOcean), Assets (over S3) and CDN Endpoint.

#### Description of the Problem:

In the case of an error, I’m only seeing the loading animation, and the errors are displayed as shown in the image below:

This is the error sceme:

| / | CDN Endpoint | “normal” Endpoint |
| --- | --- | --- |
| DISCOURSE\_S3\_BUCKET SET | ❌ Pic1 | ✅ |
| DISCOURSE\_S3\_BUCKET **NOT** SET | ✅ | ✅ |

- CDN Endpoint: `https://<bucket>.fra1.cdn.digitaloceanspaces.com`
- “normal” Endpoint: `https://<bucket>.fra1.digitaloceanspaces.com`

 ![Pic1](https://global.discourse-cdn.com/meta/original/4X/9/d/1/9d12eb3f6722ad03d2705d327295970c91d2ac7e.png)

Current Configuration:

```plaintext
  DISCOURSE_USE_S3: true

  DISCOURSE_S3_ACCESS_KEY_ID: <token>
  DISCOURSE_S3_SECRET_ACCESS_KEY: <secret>
  DISCOURSE_S3_ENDPOINT: https://fra1.digitaloceanspaces.com
  DISCOURSE_S3_CDN_URL: https://<bucket>.fra1.cdn.digitaloceanspaces.com
  #DISCOURSE_S3_BUCKET: '<bucket>' # for assets
  DISCOURSE_S3_UPLOAD_BUCKET: '<bucket>'
  DISCOURSE_S3_REGION: fra1
  DISCOURSE_BACKUP_LOCATION: s3
  DISCOURSE_S3_BACKUP_BUCKET: '<bucket>/backups '
  DISCOURSE_S3_INSTALL_CORS_RULE: false

```

I have also set the following hook (if I use the `DISCOURSE_S3_BUCKET` variable):

```plaintext
hooks:
  after_assets_precompile:
    - exec:
        cd: $home
        cmd:
          - sudo -E -u discourse bundle exec rake s3:upload_assets

```

I only encounter the error with the ‘right’ combination of configs. Any Ideas? I can also provide more information if needed.

---

<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: [July 22, 2023, 1:16pm UTC](https://meta.discourse.org/t/s3-assets-cdn-error/272504/2 "2023-07-22T13:16:42Z")

</div>

You need a different CDN. `Bunny.net` is easy.

> [@Configure an S3 compatible object storage provider for uploads](https://meta.discourse.org/t/configure-an-s3-compatible-object-storage-provider-for-uploads/148916/1):
>
> Only problem is that their CDN offering is [awfully broken](https://docs.digitalocean.com/products/spaces/how-to/set-file-metadata/), so you need to use a different CDN for the files

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [July 24, 2023, 9:15am UTC](https://meta.discourse.org/t/s3-assets-cdn-error/272504/3 "2023-07-24T09:15:53Z")

</div>

I agree that Bunny works well and is easy to configure.

I changed from Stackpath (Their CDN price has tripled last year 🙀) to Bunny on my forum recently.

As a bonus, it was also beneficial for a Chinese user:

> **[I changed the forum's CDN](https://unicyclist.com/t/i-changed-the-forums-cdn/278516/7?u=canapin)**
>
> I live in China. Actually I had to use VPN to view the pictures before (I can view the site without a VPN, but also without pictures). Now not only I have direct access to them, they are also blazingly fast!

---

<div class="post-metadata">

### Author: ![LimitlessGreen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/limitlessgreen/32/235212_2.png) [@LimitlessGreen](https://meta.discourse.org/u/LimitlessGreen)
#### Post date: [August 5, 2023, 2:47pm UTC](https://meta.discourse.org/t/s3-assets-cdn-error/272504/4 "2023-08-05T14:47:19Z")

</div>

Thank you for the suggestion!

I’m part of an open source project and the traffic at the moment wouldn’t justify using a different CDN 😅. The reason we’re using DigitalOcean is that they have a free sponsorship program for open source projects.

The thing is: It’s now kind of working with DO (pictures and uploaded stuff get’s syncronized). I set the `DISCOURSE_S3_UPLOAD_BUCKET`, but not the `DISCOURSE_S3_BUCKET`. So can you explain “awfully broken” a bit more?

The annoing thing is:

- commands like `rake uploads:s3_migration_status` do not work, because they rely on `DISCOURSE_S3_BUCKET`
- I can’t use the CDN for assets
