# הגדר ספק אחסון עצמים תואם ל-S3 להעלאות

**URL:** https://meta.discourse.org/t/configure-an-s3-compatible-object-storage-provider-for-uploads/148916
**Category:** Self-Hosting
**Tags:** cdn, configuring, how-to, reference
**Created:** [22 באפריל,‏ 2020,‏ 10:37pm UTC](https://meta.discourse.org/t/configure-an-s3-compatible-object-storage-provider-for-uploads/148916 "2020-04-22T22:37:37Z")
**Posts on this page:** 20
**Page:** 11

<div class="post-metadata">

### Author: ![Skeleton](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/skeleton/32/335075_2.png) [@Skeleton](https://meta.discourse.org/u/Skeleton)
#### Post date: [23 באוקטובר,‏ 2023,‏ 9:06pm UTC](https://meta.discourse.org/t/configure-an-s3-compatible-object-storage-provider-for-uploads/148916/436 "2023-10-23T21:06:57Z")

</div>

Contabo S3 support/compatibility will be added? or someone found a walkaround to make it works?

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [23 באוקטובר,‏ 2023,‏ 10:19pm UTC](https://meta.discourse.org/t/configure-an-s3-compatible-object-storage-provider-for-uploads/148916/437 "2023-10-23T22:19:19Z")

</div>

We, the Discourse maintainers, only support AWS S3. The providers listed here were tested by either us or the community to see if they implement enough of the S3 API to be compatible with Discourse.

Per the OP, @tuxed tested Contabo and found it lacking. It’s on Contabo to evolve their implementation compliance with S3, if they deem it aligned with their business interests, not something that can do.

---

<div class="post-metadata">

### Author: ![pythonskynet](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pythonskynet/32/350089_2.png) [@pythonskynet](https://meta.discourse.org/u/pythonskynet)
#### Post date: [20 בדצמבר,‏ 2023,‏ 7:12pm UTC](https://meta.discourse.org/t/configure-an-s3-compatible-object-storage-provider-for-uploads/148916/438 "2023-12-20T19:12:55Z")

</div>

> [@Falco](#):
>
> Only problem is that their CDN offering is [awfully broken](https://docs.digitalocean.com/products/spaces/how-to/set-file-metadata/)

Is this still buggy? Why Digitalocean CDN not good?

---

<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: [20 בדצמבר,‏ 2023,‏ 8:12pm UTC](https://meta.discourse.org/t/configure-an-s3-compatible-object-storage-provider-for-uploads/148916/439 "2023-12-20T20:12:37Z")

</div>

> [@pythonskynet](#):
>
> Why Digitalocean CDN not good?

Did you follow the links?

It looks like the CDN doesn’t now about metadata. But you could try it an see if it works! Let us know if you do. I was wondering if it had been fixed just the other day. From the looks of the documentation, I’m not going to be trying it myself any time soon.

---

<div class="post-metadata">

### Author: ![pythonskynet](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pythonskynet/32/350089_2.png) [@pythonskynet](https://meta.discourse.org/u/pythonskynet)
#### Post date: [20 בדצמבר,‏ 2023,‏ 8:57pm UTC](https://meta.discourse.org/t/configure-an-s3-compatible-object-storage-provider-for-uploads/148916/440 "2023-12-20T20:57:42Z")

</div>

I am looking for an easy way to add cdn support to my forum on digitalocean. If S3 is easier I would go with that option.

Don’t want to take risk with a setup that doesn’t worked well before.

---

<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: [20 בדצמבר,‏ 2023,‏ 9:12pm UTC](https://meta.discourse.org/t/configure-an-s3-compatible-object-storage-provider-for-uploads/148916/441 "2023-12-20T21:12:18Z")

</div>

The recommended solution is just not to use their CDN. You can use spaces, if you follow the instructions above and something like [bunny.net](http://bunny.net) for the CDN. It’s cheap and easy.

Aws S3 is what cdck uses, so it’s a bit better tested and supported, but unless you’re already handy with aws, the spaces bucket is a good solution. Just don’t use the digital ocean cdn.

---

<div class="post-metadata">

### Author: ![kgrier](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kgrier/32/207667_2.png) [@kgrier](https://meta.discourse.org/u/kgrier)
#### Post date: [23 בדצמבר,‏ 2023,‏ 4:33am UTC](https://meta.discourse.org/t/configure-an-s3-compatible-object-storage-provider-for-uploads/148916/442 "2023-12-23T04:33:08Z")

</div>

I just went through this - CDN setup, keeping images local for now - first with fastly, then some other I don’t recall. Settled on [bunny.net](http://bunny.net). very easy to set up. They have how-to specific to Discourse. We are self-hosted in DO with 100GB+ of images. 65% cache hit rate and climbing.

> **[How to speed up Discourse with BunnyCDN](https://support.bunny.net/hc/en-us/articles/360000549272-How-to-speed-up-Discourse-with-BunnyCDN)**
>
> Discourse allows you to easily integrate and speed up with BunnyCDN. This article explains two easy steps to speed up your Discourse forum.1. Create your Pull ZoneTo start, sign in to your BunnyCDN...

---

<div class="post-metadata">

### Author: ![Harrison\_Jhonson](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/harrison_jhonson/32/258721_2.png) [@Harrison\_Jhonson](https://meta.discourse.org/u/Harrison_Jhonson)
#### Post date: [14 בינואר,‏ 2024,‏ 8:58am UTC](https://meta.discourse.org/t/configure-an-s3-compatible-object-storage-provider-for-uploads/148916/443 "2024-01-14T08:58:07Z")

</div>

s3 configure tombstone policy only works on aws.amazon ?

---

<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: [15 בינואר,‏ 2024,‏ 3:31pm UTC](https://meta.discourse.org/t/configure-an-s3-compatible-object-storage-provider-for-uploads/148916/444 "2024-01-15T15:31:02Z")

</div>

No. It’s a problem only on backblaze.

> [@Falco](#):
>
> There are [reports](https://meta.discourse.org/t/backblaze-s3-issue-duplicated-uploads-after-delete/183313) of `clean up orphan uploads` not working correctly with BackBlaze. You must [change lifecycle rules](https://meta.discourse.org/t/backblaze-s3-issue-duplicated-uploads-after-delete/183313/13) for your bucket for orphan cleanup to work.
> 
> Example configuration:
> 
> ```plaintext
> DISCOURSE_USE_S3: true
> DISCOURSE_S3_REGION: "us-west-002"
> DISCOURSE_S3_INSTALL_CORS_RULE: false
> DISCOURSE_S3_CONFIGURE_TOMBSTONE_POLICY: false
> 
> ```

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [8 במרץ,‏ 2024,‏ 5:22pm UTC](https://meta.discourse.org/t/configure-an-s3-compatible-object-storage-provider-for-uploads/148916/445 "2024-03-08T17:22:07Z")

</div>

3 posts were split to a new topic: [Exploring Solutions for User Profile Picture Upload Problems](https://meta.discourse.org/t/exploring-solutions-for-user-profile-picture-upload-problems/298592)

---

<div class="post-metadata">

### Author: ![FizzGiGG](https://avatars.discourse-cdn.com/v4/letter/f/d26b3c/32.png) [@FizzGiGG](https://meta.discourse.org/u/FizzGiGG)
#### Post date: [27 במרץ,‏ 2024,‏ 11:01pm UTC](https://meta.discourse.org/t/configure-an-s3-compatible-object-storage-provider-for-uploads/148916/446 "2024-03-27T23:01:43Z")

</div>

Whew, where do I start? So, I’m using Cloudflare for caching and DNS, and Backblaze B2 for storage. I was able to get it to work, but only partially. During a ./launcher rebuild app I saw that it was uploading assets, so I was super excited that it appeared to be working. After it completed the rebuild successfully, I was unable to access the site. I just get some moving dots in the middle of the page.

Based on the Backblaze article [Deliver Public Backblaze B2 Content Through Cloudflare CDN](https://www.backblaze.com/docs/cloud-storage-deliver-public-backblaze-b2-content-through-cloudflare-cdn) I have set a Proxied CNAME record that points to the Friendly URL origin [f000.backblazeb2.com](http://f000.backblazeb2.com) called gtech-cdn.

**CNAME gtech-cdn → [f000.backblazeb2.com](http://f000.backblazeb2.com)**

The article also talks about Page Rules; I have tried toggling them on and off to no avail.

Here’s the pertinent configuration items:

```plaintext
  DISCOURSE_HOSTNAME: mmhmm.com

  DISCOURSE_CDN_URL: https://mmhmm.com

  DISCOURSE_USE_S3: true
  DISCOURSE_S3_REGION: us-west-000
  DISCOURSE_S3_ENDPOINT: https://s3.us-west-000.backblazeb2.com
  DISCOURSE_S3_ACCESS_KEY_ID: <secret>
  DISCOURSE_S3_SECRET_ACCESS_KEY: <secret>
  DISCOURSE_S3_CDN_URL: https://gtech-cdn.mmhmm.com
  DISCOURSE_S3_BUCKET: gtech-uploads
  DISCOURSE_S3_BACKUP_BUCKET: gtech-uploads/backups
  DISCOURSE_BACKUP_LOCATION: s3

Under the **hooks:** section...

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

```

One of the things that is confusing to me is what to put in the two variables DISCOURSE\_S3\_CDN\_URL, and DISCOURSE\_CDN\_URL. Do I have them set properly based on the info that I have provided?

Looking at the browser dev tools console, I’m getting 404 errors on .js scripts. The URL doesn’t appear that it is being built properly. Shouldn’t it have /file/ in there before /assets? If I add that manually to create a proper URL, it works:

`https://gtech-cdn.mmhmm.com/file/gtech-uploads/assets/google-universal-analytics-v4-e154af4adb3c483a3aba7f9a7229b8881cdc5cf369290923d965a2ad30163ae8.br.js`

 ![image](https://global.discourse-cdn.com/meta/original/4X/8/1/9/8197f92375180facccf0b2913fdff01d0d801636.png)

Thanks for any help, it’s much appreciated!!!

---

<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: [28 במרץ,‏ 2024,‏ 9:28am UTC](https://meta.discourse.org/t/configure-an-s3-compatible-object-storage-provider-for-uploads/148916/447 "2024-03-28T09:28:35Z")

</div>

[https://gtech-cdn.mmhmm.com](https://gtech-cdn.mmhmm.com) doesn’t resolve, so that’s the first thing to fix. .

I’m not sure that you can use cloudflare as acdn like that, but maybe I’m wrong.

---

<div class="post-metadata">

### Author: ![FizzGiGG](https://avatars.discourse-cdn.com/v4/letter/f/d26b3c/32.png) [@FizzGiGG](https://meta.discourse.org/u/FizzGiGG)
#### Post date: [28 במרץ,‏ 2024,‏ 12:25pm UTC](https://meta.discourse.org/t/configure-an-s3-compatible-object-storage-provider-for-uploads/148916/448 "2024-03-28T12:25:22Z")

</div>

Sorry, I should have mentioned that [mmhmm.com](http://mmhmm.com) is a fake domain. It does respond to a ping.

 ![image](https://global.discourse-cdn.com/meta/original/4X/3/a/8/3a88396126dc444560ff72de4cb16e0584958f48.png)

As far as Cloudflare not being able to be used as a CDN, I guess I’m not following. The [article](https://www.backblaze.com/docs/cloud-storage-deliver-public-backblaze-b2-content-through-cloudflare-cdn) I linked clearly is for using it as a CDN. If that is not true, then again, what values are to be used in the two variables DISCOURSE\_S3\_CDN\_URL, and DISCOURSE\_CDN\_URL?

Cheers,

---

<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: [28 במרץ,‏ 2024,‏ 12:30pm UTC](https://meta.discourse.org/t/configure-an-s3-compatible-object-storage-provider-for-uploads/148916/449 "2024-03-28T12:30:20Z")

</div>

If you give fake urls you can only get fake answers.

Does the url serve the data that is expected? Can you retrieve it from the forum url?

I think the s3 cdn should work. It’s using the forum url for the forum cdn they I’m not sure about.

A normal cdn is a different url than the forum and the cdn can count on the data being static rather than having to guess what’s dynamic

---

<div class="post-metadata">

### Author: ![FizzGiGG](https://avatars.discourse-cdn.com/v4/letter/f/d26b3c/32.png) [@FizzGiGG](https://meta.discourse.org/u/FizzGiGG)
#### Post date: [28 במרץ,‏ 2024,‏ 12:55pm UTC](https://meta.discourse.org/t/configure-an-s3-compatible-object-storage-provider-for-uploads/148916/450 "2024-03-28T12:55:52Z")

</div>

I do my best not to plaster my information across various forums, so please excuse my secrecy on the matter.

The forum sits at “[https://mmhmm.com](https://mmhmm.com)”, which is a Cloudflare DNS record that is proxied (cached). Prior to configuring Discourse to use Backblaze it all functioned properly.

“[https://gtech-cdn.mmhmm.com](https://gtech-cdn.mmhmm.com)”, as stated previously, resolves and also responds to a ping. The target of the CNAME record, [f000.backblazeb2.com](http://f000.backblazeb2.com), also resolves. That B2 Friendly URL origin is what the article instructs you to use. That isn’t the issue though. The issue is that Discourse is serving up URLs for the .js files using an invalid URL that will never work as it is missing that “/file/gtech-cdn” part of the path. If you take one of those incomplete .js URLS and add that missing info to it manually, it will load the text of the .js file just fine.

Of course, I’m still trying to wrap my head around how this is all supposed to be working with those two variables. I’m more of a visual learner and could really use a flow chart or something to help me understand what’s supposed to be happening with the interactions between Cloudflare CDN, Discourse, and Backblaze B2.

Thanks for your help.

---

<div class="post-metadata">

### Author: ![FizzGiGG](https://avatars.discourse-cdn.com/v4/letter/f/d26b3c/32.png) [@FizzGiGG](https://meta.discourse.org/u/FizzGiGG)
#### Post date: [28 במרץ,‏ 2024,‏ 1:59pm UTC](https://meta.discourse.org/t/configure-an-s3-compatible-object-storage-provider-for-uploads/148916/451 "2024-03-28T13:59:32Z")

</div>

Oh, and I’ll try to address your last sentence about a normal cdn…

The article from Backblaze has you create two page rules per bucket (in my case 1 bucket is used), which if I am understanding it correctly is sort of like a firewall rule in the way it processes.

Rule 1 says that [https://gtech-cdn.mmhmm.com/file/\*/](https://gtech-cdn.mmhmm.com/file/*/)\* should use standard caching (which is set elsewhere in Cloudflare to 1 month)  
Rule 2 redirects anything (302 - temp redir) that doesn’t match the Rule 1 pattern.

So not everything will be cached by going to [mmhmm.com](http://mmhmm.com)… at least that is my understanding

---

<div class="post-metadata">

### Author: ![FizzGiGG](https://avatars.discourse-cdn.com/v4/letter/f/d26b3c/32.png) [@FizzGiGG](https://meta.discourse.org/u/FizzGiGG)
#### Post date: [28 במרץ,‏ 2024,‏ 7:44pm UTC](https://meta.discourse.org/t/configure-an-s3-compatible-object-storage-provider-for-uploads/148916/452 "2024-03-28T19:44:59Z")

</div>

EDIT: This did not work.  
Focusing on this a little bit more, I decided for obvious reasons that I should use the S3 URL as the CNAME target instead of the Friendly URL that the Backblaze article suggested. I’m now just waiting on the DNS record TTL to expire.

 ![image](https://global.discourse-cdn.com/meta/original/4X/7/f/7/7f7bbe8224207c16431dcc76820e414b2dd4748c.png)

---

<div class="post-metadata">

### Author: ![Jeff\_Vienneau](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jeff_vienneau/32/108772_2.png) [@Jeff\_Vienneau](https://meta.discourse.org/u/Jeff_Vienneau)
#### Post date: [4 באפריל,‏ 2024,‏ 12:09am UTC](https://meta.discourse.org/t/configure-an-s3-compatible-object-storage-provider-for-uploads/148916/453 "2024-04-04T00:09:22Z")

</div>

Regarding this hook:

> [@Falco](#):
>
> ```plaintext
> after_assets_precompile:
> - exec:
> cd: $home
> cmd:
> - sudo -E -u discourse bundle exec rake s3:upload_assets
> - sudo -E -u discourse bundle exec rake s3:expire_missing_assets
> 
> ```

I don’t see anything with s3 in the `rake --tasks` dump. Is this still relevant or am I missing some plugin?

Also seeing this when I manually run:  
`uploads:migrate_to_s3`

```plaintext
rake aborted!
FileStore::ToS3MigrationError: Some uploads could not be migrated to the new scheme. You need to fix this manually. (FileStore::ToS3MigrationError)
/var/www/discourse/lib/file_store/to_s3_migration.rb:156:in `migrate_to_s3'
/var/www/discourse/lib/file_store/to_s3_migration.rb:59:in `migrate'
/var/www/discourse/lib/tasks/uploads.rake:126:in `migrate_to_s3'
/var/www/discourse/lib/tasks/uploads.rake:106:in `block in migrate_to_s3_all_sites'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rails_multisite-6.0.0/lib/rails_multisite/connection_management/null_instance.rb:49:in `with_connection'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rails_multisite-6.0.0/lib/rails_multisite/connection_management/null_instance.rb:36:in `each_connection'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rails_multisite-6.0.0/lib/rails_multisite/connection_management.rb:21:in `each_connection'
/var/www/discourse/lib/tasks/uploads.rake:104:in `migrate_to_s3_all_sites'
/var/www/discourse/lib/tasks/uploads.rake:100:in `block in <main>'
/usr/local/bin/bundle:25:in `load'
/usr/local/bin/bundle:25:in `<main>'
Tasks: TOP => uploads:migrate_to_s3
(See full trace by running task with --trace)
root@ubuntu-s-2vcpu-4gb-nyc2-01-app:/var/www/discourse# 
root@ubuntu-s-2vcpu-4gb-nyc2-01-app:/var/www/discourse# rake uploads:migrate_to_s3
Please note that migrating to S3 is currently not reversible! 

```

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [26 באפריל,‏ 2024,‏ 5:31pm UTC](https://meta.discourse.org/t/configure-an-s3-compatible-object-storage-provider-for-uploads/148916/454 "2024-04-26T17:31:58Z")

</div>

6 posts were split to a new topic: [Cloudflare R2: Navigating Setup and Handling Configuration Errors](https://meta.discourse.org/t/cloudflare-r2-navigating-setup-and-handling-configuration-errors/305617)

---

<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: [30 באפריל,‏ 2024,‏ 7:25pm UTC](https://meta.discourse.org/t/configure-an-s3-compatible-object-storage-provider-for-uploads/148916/455 "2024-04-30T19:25:55Z")

</div>

Looks like Cloudflare works now:

See [Cloudflare R2: Navigating Setup and Handling Configuration Errors - #13 by pfaffman](https://meta.discourse.org/t/cloudflare-r2-navigating-setup-and-handling-configuration-errors/305617/13)

[Previous page](https://meta.discourse.org/t/configure-an-s3-compatible-object-storage-provider-for-uploads/148916.md?page=10)

[Next page](https://meta.discourse.org/t/configure-an-s3-compatible-object-storage-provider-for-uploads/148916.md?page=12)
