Basic How-To for Using MinIO storage server run by you for your Discourse Instance

Utilizing MinIO server for S3 compatible object storage

MinIO is an S3-compatible object storage server solution that is cloud-native by default but easy to deploy on on-prem servers or VPSes or cloud servers for your use as an alternative to Amazon AWS S3 or other systems, and is compatible with Discourse when configured right.

This section presupposes that the following are true in your environment:

  1. You have a fully configured MinIO server instance
  2. You have Domain Support enabled in the MinIO configuration
  3. You have DNS configuration properly set up for MinIO so that bucket subdomains properly resolve to the MinIO server
  4. The bucket discourse-data exists on the MinIO server and has a ā€œpublicā€ policy set on it
  5. The bucket discourse-backups exists on the MinIO server and is a private bucket for uploads to be put into (and not publicly reachable - the default policy for new buckets)
  6. Your S3 CDN URL is a properly configured CDN pointing to the bucket and cache requests, as stated earlier in this document.

If you have all of the above requirements available, then you should be good to go.

An example configuration would be like this:

DISCOURSE_USE_S3: true
DISCOURSE_S3_REGION: anything
DISCOURSE_S3_ENDPOINT: https://minio.example.com
DISCOURSE_S3_ACCESS_KEY_ID: myaccesskey
DISCOURSE_S3_SECRET_ACCESS_KEY: mysecretkey
DISCOURSE_S3_CDN_URL: https://discourse-data-cdn.example.com
DISCOURSE_S3_BUCKET: discourse-data
DISCOURSE_S3_BACKUP_BUCKET: discourse-backups
DISCOURSE_BACKUP_LOCATION: s3

This will provide you with a basic MinIO configuration with a MinIO server in place of Amazon S3.

4 Likes

Itā€™s great to know that MinIO now works fine with subdomain style buckets and is again compatible with Discourse.

Can you edit the Using Object Storage for Uploads (S3 & Clones) wiki to include MinIO instructions?

3 Likes

Itā€™s worked with both subdomain AND path style buckets for a while. However, the DNS configuration component is the most painful component - it needs special wildcard DNS rules to work, or a customized DNS server that is actively aware of all actual buckets or not. Iā€™ve done that in bind9 with wildcard zones, but doing it in Cloudflare or others and the subdomain style bits barf hard.

IF you think the above is suitable to be in that section, Iā€™ll be happy to. But itā€™ll include that ā€˜caveatsā€™ section - and Iā€™d appreciate any exits/reviews youā€™d like me to make first for wording, etc. (And note I didnā€™t include a CDN URL 'cause I donā€™t have a CDN in my deployment (because $$$ is not something I can experiment with).

3 Likes

Users who run MinIO just for Discourse can also create the DNS entries for the 2 Discourse buckets manually too right?

The caveat in this topic should be enough. Configuring MinIO is completely out of scope for this forum, but given a working MinIO getting Discourse to use is a valid use case.

2 Likes

Correct, but as you said config is out of scope, so I simply will state that the bucket subdomain paths have to resolve (and will leave DNS config to ${ADMINS} of the instance)

2 Likes

Yep, and I"ve edited the wiki accordingly. However, MinIO doesnā€™t (to my knowledge) run a cloud service so I left the ā€˜Service Nameā€™ in the wiki TOC at the beginning blank, adjust accordingly if you wish.

2 Likes

Awesome! Thanks for the contribution!

1 Like

Youā€™re welcome!

I also tweaked it, Provider is Self-hosted but the MinIO section is still linked to. That should solve the fact they donā€™t have a cloud provided solution that I could find at the moment. (You can close this thread now if you wish since itā€™s integrated into the wiki post)

3 Likes

Also discovered (thank you open source code and decent documentation for MinIO!) that CORS is already by default on all MinIO HTTP action verbs - so no need to install the CORS rules, theyā€™re already present. Also updated the self-hosted minio section as well, plus some grammar tweaks.

Thanks to @Falco for some help tracing the issue I had noticed during app build / rebuild time for this, and for the base guidance on CDN config with StackPath (because I wanted a fully functional test, and have StackPath CDN for something else anyways so using the CDN stack verified everything worked!)

2 Likes

I donā€™t get it how to set the force path style. When I set up version 2.6.8 with minio via the S3 settings it always prepends the bucket name to the s3 endpoint, where it should append it as path after the s3 endpoint.

It also looks from the config sample on github that the option s3_force_path_style has been removed. Am I missing something? Thank you.

@ceelian

Discourse uses DNS mode, not path mode, for S3. Itā€™s been that way for a WHILE now, itā€™s why I donā€™t specify anything about path mode in the how to OR the S3-storage how to page. You should also learn how to make new threads rather than necromancing an old thread up for something unrelated.

1 Like

@teward Thank you for the feedback. Sorry, for necromancing, I am used to the GitHub issues way of writing :slight_smile: I will start a new thread for how we can use discourse S3 in path mode.

FYI: you canā€™t. I donā€™t believe that path mode is supported anymore, which is why that option to force path mode for Discourse is gone. Itā€™s also why the section I originally added to the S3 compatible object storage how-to page now says under caveats and requirements:

  1. You have Domain Support enabled in the MinIO configuration, for Domain driven bucket URLs. This is mandatory and not an option, there is no path-based support in Discourse for bucket paths.

A long time ago when I first was working with Discourse, they had that option, then it got removed, and I had to stop using MinIO as a backend. NOW, since thereā€™s documentation in MinIO on how to get DNS mode working (i.e. bucket[.]server[.]com paths now like S3 does), it works when you properly configure MinIO. (Thank you to the staff/moderators/system for upping my trust level to edit the wiki itself now).

2 Likes

Thank you for the clarification and hint on how to resolve the issue!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.