# Extend S3 configuration for other s3 API compatible cloud storage solutions

**URL:** https://meta.discourse.org/t/extend-s3-configuration-for-other-s3-api-compatible-cloud-storage-solutions/20593
**Category:** Feature
**Created:** [September 29, 2014, 3:47pm UTC](https://meta.discourse.org/t/extend-s3-configuration-for-other-s3-api-compatible-cloud-storage-solutions/20593 "2014-09-29T15:47:57Z")
**Posts on this page:** 20
**Page:** 2

<div class="post-metadata">

### Author: ![tophee](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tophee/32/73406_2.png) [@tophee](https://meta.discourse.org/u/tophee)
#### Post date: [September 25, 2017, 8:34am UTC](https://meta.discourse.org/t/extend-s3-configuration-for-other-s3-api-compatible-cloud-storage-solutions/20593/21 "2017-09-25T08:34:38Z")

</div>

> [@Uninen](#):
>
> I’m very much +1 on bringing support for the likes of Backblaze B2 in.

Just to be clear, though: [Backblaze is not S3 compatible](https://help.backblaze.com/hc/en-us/articles/218513487-Is-the-B2-Cloud-Storage-API-Compatible-with-Amazon-S3).

---

<div class="post-metadata">

### Author: ![itsbhanusharma](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/itsbhanusharma/32/180717_2.png) [@itsbhanusharma](https://meta.discourse.org/u/itsbhanusharma)
#### Post date: [November 15, 2017, 12:05pm UTC](https://meta.discourse.org/t/extend-s3-configuration-for-other-s3-api-compatible-cloud-storage-solutions/20593/23 "2017-11-15T12:05:10Z")

</div>

Just Curious to know if this functionality is available to be tested as me & my team pretty much testing our discourse setup prior to launch and are open to trying out such features. DO spaces looks like an attractive deal if it can be implemented with Discourse without much hassle. can anyone here shed some light on how is AmazonS3 implemented? (hardcoded stuff or propritary content or apis etc?) Surely gonna look at it.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [November 15, 2017, 8:19pm UTC](https://meta.discourse.org/t/extend-s3-configuration-for-other-s3-api-compatible-cloud-storage-solutions/20593/24 "2017-11-15T20:19:24Z")

</div>

Step 1:

Demonstrating in code how you would get aws-s3 gem to talk to a different provider. I have not researched that yet but that is the first blocker here.

This may not be trivial considering amazon are the ones maintaining that gem.

---

<div class="post-metadata">

### Author: ![schungx](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/schungx/32/70989_2.png) [@schungx](https://meta.discourse.org/u/schungx)
#### Post date: [November 16, 2017, 2:06pm UTC](https://meta.discourse.org/t/extend-s3-configuration-for-other-s3-api-compatible-cloud-storage-solutions/20593/25 "2017-11-16T14:06:06Z")

</div>

Azure has blob storage which is not s3 api compatible but is a similar service…

EDIT: Sorry probably shouldn’t be replying to a post years ago. Sorry to disrupt the thread.

---

<div class="post-metadata">

### Author: ![ckshen](https://avatars.discourse-cdn.com/v4/letter/c/ad7895/32.png) [@ckshen](https://meta.discourse.org/u/ckshen)
#### Post date: [January 21, 2018, 6:37am UTC](https://meta.discourse.org/t/extend-s3-configuration-for-other-s3-api-compatible-cloud-storage-solutions/20593/28 "2018-01-21T06:37:39Z")

</div>

I am late to this party. Any conclusion around the nature/ volume of work involved?

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [January 21, 2018, 10:50pm UTC](https://meta.discourse.org/t/extend-s3-configuration-for-other-s3-api-compatible-cloud-storage-solutions/20593/29 "2018-01-21T22:50:20Z")

</div>

> [@ckshen](#):
>
> Any conclusion around the nature/ volume of work involved?

This is totally unknown until this is answered.

> [@sam](#):
>
> Step 1:
> 
> Demonstrating in code how you would get aws-s3 gem to talk to a different provider. I have not researched that yet but that is the first blocker here.
> 
> This may not be trivial considering amazon are the ones maintaining that gem.

---

<div class="post-metadata">

### Author: ![arrowcircle](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arrowcircle/32/100035_2.png) [@arrowcircle](https://meta.discourse.org/u/arrowcircle)
#### Post date: [February 14, 2018, 8:36am UTC](https://meta.discourse.org/t/extend-s3-configuration-for-other-s3-api-compatible-cloud-storage-solutions/20593/30 "2018-02-14T08:36:00Z")

</div>

Maybe this will help? [https://docs.minio.io/docs/how-to-use-aws-sdk-for-ruby-with-minio-server](https://docs.minio.io/docs/how-to-use-aws-sdk-for-ruby-with-minio-server)

Minio is s3 compatible storage, so it should be similar configuration with DO Spaces.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [February 14, 2018, 9:16am UTC](https://meta.discourse.org/t/extend-s3-configuration-for-other-s3-api-compatible-cloud-storage-solutions/20593/31 "2018-02-14T09:16:47Z")

</div>

Trouble is Amazon control the aws-sdk gem and don’t appear to provide easy extensibility to which urls you hit.

---

<div class="post-metadata">

### Author: ![arrowcircle](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arrowcircle/32/100035_2.png) [@arrowcircle](https://meta.discourse.org/u/arrowcircle)
#### Post date: [February 14, 2018, 10:21am UTC](https://meta.discourse.org/t/extend-s3-configuration-for-other-s3-api-compatible-cloud-storage-solutions/20593/32 "2018-02-14T10:21:21Z")

</div>

You dont need to make changes in Amazon aws-sdk gem. As I understand, its higher level (storage), where s3 client is initialized. Changes are in the initialization params of sdk, not in the gem itself.

At first, it looks like here is the place to add custom endpoint [https://github.com/discourse/discourse/blob/4f28c71b5082d8194129f10084738775b36b8ed3/lib/s3\_helper.rb#L152](https://github.com/discourse/discourse/blob/4f28c71b5082d8194129f10084738775b36b8ed3/lib/s3_helper.rb#L152)

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [February 15, 2018, 8:30pm UTC](https://meta.discourse.org/t/extend-s3-configuration-for-other-s3-api-compatible-cloud-storage-solutions/20593/33 "2018-02-15T20:30:39Z")

</div>

hmmm but that place just lets you choose “aws region” how would we enter a completely different HTTPS based endpoint there?

---

<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: [February 15, 2018, 8:51pm UTC](https://meta.discourse.org/t/extend-s3-configuration-for-other-s3-api-compatible-cloud-storage-solutions/20593/34 "2018-02-15T20:51:19Z")

</div>

[https://github.com/aws/aws-sdk-ruby/issues/1616#issuecomment-329991391](https://github.com/aws/aws-sdk-ruby/issues/1616#issuecomment-329991391)

Looks like we can add a `s3_endpoint` setting that defaults to aws when empty?

---

<div class="post-metadata">

### Author: ![youwiki](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/youwiki/32/89936_2.png) [@youwiki](https://meta.discourse.org/u/youwiki)
#### Post date: [February 17, 2018, 12:20pm UTC](https://meta.discourse.org/t/extend-s3-configuration-for-other-s3-api-compatible-cloud-storage-solutions/20593/35 "2018-02-17T12:20:10Z")

</div>

Hello!

We use the Minio on our site as s3 compatible storage without any problems.

So to make it works, it is necessary:

Add to `s3_options` (`/lib/s3_helper.rb`) your s3 compatible storage endpoint, and `force_path_style` param depending on its settings:

```plaintext
opts = {region: obj.s3_region, endpoint: 'http://minio:9000', force_path_style: true}

```

and modify `absolute_base_url` setting (`/app/models/site_setting.rb`) to return this:

```plaintext
def self.absolute_base_url
  bucket = SiteSetting.enable_s3_uploads ? Discourse.store.s3_bucket_name : GlobalSetting.s3_bucket

  return "//files.you_site.tld/#{bucket}"
end

```

Also, you need to make the appropriate settings for your nginx server.

It’s work fine, but there is one problem, particularly with Minio, that should be solved - `update_lifecycle` - Minio does not support this.

---

<div class="post-metadata">

### Author: ![arrowcircle](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arrowcircle/32/100035_2.png) [@arrowcircle](https://meta.discourse.org/u/arrowcircle)
#### Post date: [March 7, 2018, 11:04am UTC](https://meta.discourse.org/t/extend-s3-configuration-for-other-s3-api-compatible-cloud-storage-solutions/20593/36 "2018-03-07T11:04:04Z")

</div>

So any ideas how to port this settings to original codebase?  
Or how to add script to change this code after updates?

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [March 7, 2018, 9:46pm UTC](https://meta.discourse.org/t/extend-s3-configuration-for-other-s3-api-compatible-cloud-storage-solutions/20593/37 "2018-03-07T21:46:06Z")

</div>

> [@arrowcircle](#):
>
> Or how to add script to change this code after updates?

This is PR welcome, the correct way is to have a PR that adds the feature.

---

<div class="post-metadata">

### Author: ![arrowcircle](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arrowcircle/32/100035_2.png) [@arrowcircle](https://meta.discourse.org/u/arrowcircle)
#### Post date: [March 12, 2018, 9:48am UTC](https://meta.discourse.org/t/extend-s3-configuration-for-other-s3-api-compatible-cloud-storage-solutions/20593/38 "2018-03-12T09:48:50Z")

</div>

What setting do I need to change in nginx config? For minio or discourse or both?

---

<div class="post-metadata">

### Author: ![youwiki](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/youwiki/32/89936_2.png) [@youwiki](https://meta.discourse.org/u/youwiki)
#### Post date: [March 19, 2018, 2:21pm UTC](https://meta.discourse.org/t/extend-s3-configuration-for-other-s3-api-compatible-cloud-storage-solutions/20593/39 "2018-03-19T14:21:54Z")

</div>

Just add something like that to your nginx.conf file:

```plaintext
upstream storage {
  server minio:9000;
}

server {
  listen 80;
  server_name files.you_site.ltd;

  access_log off;

  return 301 https://files.you_site.ltd$request_uri;
}

server {
  listen 443 ssl http2;
  server_name files.you_site.ltd;

  ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA;
  ssl_prefer_server_ciphers on;
  ssl_ecdh_curve secp384r1:prime256v1;

  ssl_certificate /shared/ssl/you_site.ltd.cer;
  ssl_certificate_key /shared/ssl/you_site.ltd.key;

  ssl_session_tickets off;
  ssl_session_timeout 1d;
  ssl_session_cache shared:SSL:1m;

  add_header Strict-Transport-Security 'max-age=63072000'; # remember the certificate for a year and automatically connect to HTTPS for this domain

  access_log off;
  error_log /var/log/nginx/error.log;

  if ($http_host != files.you_site.ltd) {
    rewrite (.*) https://files.you_site.ltd$1 permanent;
  }

  location / {
    limit_conn connperip 30;
    limit_req zone=flood burst=12 nodelay;
    limit_req zone=bot burst=200 nodelay;

    add_header X-Cache-Status $upstream_cache_status;
    add_header Referrer-Policy 'no-referrer-when-downgrade';
    add_header Strict-Transport-Security 'max-age=63072000';

    proxy_cache one;
    proxy_cache_revalidate on;
    proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
    proxy_cache_lock on;
    proxy_cache_valid 1m;

    proxy_ignore_headers Set-Cookie;
    proxy_set_header Host $http_host;

    proxy_pass http://storage;
  }
}

```

This settings just for Minio, it’s not overwrite any Discourse specified Nginx settings.

If you have “Let’s encrypt” enabled, you also should change `LE_WORKING_DIR` var in `Docker/templates/web.letsencrypt.ssl.template.yml` to:

```plaintext
LE_WORKING_DIR="${LETSENCRYPT_DIR}" $$ENV_LETSENCRYPT_DIR/acme.sh --issue -d $$ENV_YOUR_SITE_HOSTNAME -d $$ENV_YOUR_SITE_STORAGE_HOSTNAME -k 4096 -w /var/www/discourse/public

if [! "$(cd $$ENV_LETSENCRYPT_DIR/$$ENV_YOUR_SITE_HOSTNAME && openssl verify -CAfile ca.cer fullchain.cer | grep "OK")"]; then
    # Try to issue the cert again if something goes wrong
    LE_WORKING_DIR="${LETSENCRYPT_DIR}" $$ENV_LETSENCRYPT_DIR/acme.sh --issue -d $$ENV_YOUR_SITE_HOSTNAME -d $$ENV_YOUR_SITE_STORAGE_HOSTNAME -k 4096 --force -w /var/www/discourse/public
fi

```

---

<div class="post-metadata">

### Author: ![Alankrit\_Choudh](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/alankrit_choudh/32/119698_2.png) [@Alankrit\_Choudh](https://meta.discourse.org/u/Alankrit_Choudh)
#### Post date: [June 27, 2018, 5:38pm UTC](https://meta.discourse.org/t/extend-s3-configuration-for-other-s3-api-compatible-cloud-storage-solutions/20593/40 "2018-06-27T17:38:04Z")

</div>

so does discourse support digital ocean spaces?

---

<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: [June 27, 2018, 6:51pm UTC](https://meta.discourse.org/t/extend-s3-configuration-for-other-s3-api-compatible-cloud-storage-solutions/20593/41 "2018-06-27T18:51:48Z")

</div>

![](https://global.discourse-cdn.com/meta/original/3X/0/d/0d359c17dddbdf08e584d6a1dfe02e0a18fcf23b.gif)

Soon…

---

<div class="post-metadata">

### Author: ![Alankrit\_Choudh](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/alankrit_choudh/32/119698_2.png) [@Alankrit\_Choudh](https://meta.discourse.org/u/Alankrit_Choudh)
#### Post date: [June 28, 2018, 3:48pm UTC](https://meta.discourse.org/t/extend-s3-configuration-for-other-s3-api-compatible-cloud-storage-solutions/20593/42 "2018-06-28T15:48:36Z")

</div>

Thanks @Falco cant wait for this!!

 ![tenor](https://global.discourse-cdn.com/meta/original/3X/7/3/73f948ef50210f35a622fbf9ecd5353d18c84267.gif)

---

<div class="post-metadata">

### Author: ![rishabh](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rishabh/32/179446_2.png) [@rishabh](https://meta.discourse.org/u/rishabh)
#### Post date: [July 4, 2018, 5:58am UTC](https://meta.discourse.org/t/extend-s3-configuration-for-other-s3-api-compatible-cloud-storage-solutions/20593/43 "2018-07-04T05:58:30Z")

</div>

Hi Alexander, that’s correct!  
Minio works great for backups only but did you ever get Minio to work for hosting image uploads? 🙂

**Edit:** For anyone in this thread who has used Minio in the past, have you ever managed to access Minio objects using virtual-host style requests? e.g. [http://bucketname.endpoint/original/1X/xyz.jpg](http://bucketname.endpoint/original/1X/xyz.jpg)

[Previous page](https://meta.discourse.org/t/extend-s3-configuration-for-other-s3-api-compatible-cloud-storage-solutions/20593.md?page=1)

[Next page](https://meta.discourse.org/t/extend-s3-configuration-for-other-s3-api-compatible-cloud-storage-solutions/20593.md?page=3)
