Como usar o servidor de armazenamento MinIO executado por você para sua instância do Discourse

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 curtidas

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 curtidas

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 curtidas

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 curtidas

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 curtidas

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 curtidas

Awesome! Thanks for the contribution!

1 curtida

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 curtidas

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 curtidas

Não entendi como configurar o estilo de caminho forçado. Quando configuro a versão 2.6.8 com Minio através das configurações S3, ele sempre anexa o nome do bucket ao endpoint S3, onde deveria anexá-lo como caminho após o endpoint S3.

Parece também, pela amostra de configuração no GitHub, que a opção s3_force_path_style foi removida. Estou perdendo alguma coisa? Obrigado.

@ceelian

O Discourse usa o modo DNS, não o modo de caminho, para S3. É assim há MUITO TEMPO, é por isso que não especifico nada sobre o modo de caminho no guia OU na página do guia de armazenamento S3. Você também deve aprender a criar novas threads em vez de ressuscitar uma thread antiga para algo não relacionado.

1 curtida

@teward Obrigado pelo feedback. Desculpe por ressuscitar o tópico, estou acostumado com a forma de escrever do GitHub issues :slight_smile: Vou iniciar um novo tópico sobre como podemos usar o Discourse S3 no modo de caminho.

FYI: você não pode. Não acredito que o modo de caminho seja mais suportado, e é por isso que a opção de forçar o modo de caminho para o Discourse desapareceu. É também por isso que a seção que originalmente adicionei à página de como configurar um provedor de armazenamento de objetos compatível com S3 agora diz, sob ressalvas e requisitos:

  1. Você tem o Suporte de Domínio habilitado na configuração do MinIO, para URLs de bucket orientadas por domínio. Isso é obrigatório e não uma opção, não há suporte baseado em caminho no Discourse para caminhos de bucket.

Há muito tempo, quando comecei a trabalhar com o Discourse, eles tinham essa opção, depois ela foi removida e tive que parar de usar o MinIO como backend. AGORA, como há documentação no MinIO sobre como fazer o modo DNS funcionar (ou seja, caminhos bucket[.]server[.]com agora como o S3 faz), ele funciona quando você configura o MinIO corretamente. (Obrigado à equipe/moderadores/sistema por aumentar meu nível de confiança para editar a própria wiki agora).

2 curtidas

Obrigado pelo esclarecimento e pela dica de como resolver o problema!

Este tópico foi automaticamente fechado 24 horas após a última resposta. Novas respostas não são mais permitidas.