为您的 Discourse 实例运行 MinIO 存储服务器的基础教程

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 个赞

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 个赞

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 个赞

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 个赞

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 个赞

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 个赞

Awesome! Thanks for the contribution!

1 个赞

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 个赞

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 个赞

我不知道如何设置强制路径样式。当我通过 S3 设置配置 2.6.8 版本和 minio 时,它总是将存储桶名称添加到 S3 端点的前面,而它应该将其作为路径附加到 S3 端点之后。

从 GitHub 上的配置示例来看,s3_force_path_style 选项似乎已被删除。我是否遗漏了什么?谢谢。

@ceelian

Discourse 使用 S3 的 DNS 模式,而不是路径模式。它已经这样很久了,这就是为什么我在操作指南或 S3 存储操作指南页面中没有指定任何关于路径模式的内容。你也应该学会如何发新帖,而不是为了不相关的事情去挖坟。

1 个赞

@teward 感谢您的反馈。抱歉,我习惯了 GitHub issue 的写法 :slight_smile: 我将开一个新帖讨论我们如何使用 discourse S3 的路径模式。

供参考:你不能。我不认为路径模式还受支持,这就是为什么强制 Discourse 使用路径模式的选项已消失的原因。这也是为什么我在 S3 兼容对象存储操作指南中最初添加的部分(https://meta.discourse.org/t/configure-an-s3-compatible-object-storage-provider-for-uploads/148916#minio-storage-server-9)现在在注意事项和要求下说明:

  1. 您已在 MinIO 配置中启用域名支持,用于域名驱动的存储桶 URL。这是强制性的,不是一个选项,Discourse 不支持基于路径的存储桶路径。

很久以前,当我第一次使用 Discourse 时,他们有这个选项,然后它被删除了,我不得不停止使用 MinIO 作为后端。现在,由于 MinIO 有关于如何使 DNS 模式工作的文档(即像 S3 那样的存储桶[.]服务器[.]com 路径),当您正确配置 MinIO 时,它就可以工作。(感谢工作人员/版主/系统将我的信任级别提高到可以编辑维基本身了)。

2 个赞

感谢您的澄清和关于如何解决问题的提示!

此主题在上次回复后 24 小时自动关闭。不再允许回复。