업로드를 위해 S3 호환 객체 저장소 제공자 구성하기

:information_source: 이 주제는 몇 가지 일반적인 S3 호환 Object Storage 제공업체(S3 클론)를 설정하는 방법에 대해 다룹니다. 공식적으로 지원되며 Discourse의 호스팅 서비스에서 내부적으로 사용되는 Amazon AWS S3 설정에 대한 자세한 내용은 Set up file and image uploads to S3 를 참조하세요.

제공업체 서비스 이름 Discourse와 호환?
Amazon AWS S3
Digital Ocean Spaces
Linode Object Storage
Google Cloud Storage
Scaleway Object Storage
Vultr Object Storage
BackBlaze Cloud Storage 예*
셀프 호스팅 MinIO
Azure Blob Storage Flexify.IO
Oracle Cloud Object Storage 아니오 [1]
Wasabi Object Storage 가능
Cloudflare R2
Contabo Object Storage 아니오

다른 서비스가 작동하도록 설정했다면, 이 위키에 추가해 주세요.

설정

Discourse 정적 자산을 Object Storage에 저장하려면 app.ymlhooks 섹션에 다음 설정을 추가하세요:

  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

Object Storage를 사용할 경우, 버킷에 저장된 콘텐츠를 서빙하기 위해 CDN이 필요합니다. 테스트에서는 StackPath CDN을 사용했으며, 설정에서 Dynamic Caching By Header: Accept-Encoding을 설정해야 하는 것을 제외하고는 잘 작동했습니다.

DISCOURSE_CDN_URL은 Discourse 호스트 이름으로 가리키고 요청을 캐시하는 CDN입니다. 주로 가져올 수 있는 자산인 CSS 및 기타 테마 자산에 사용됩니다.

DISCOURSE_S3_CDN_URL은 Object Storage 버킷으로 가리키고 요청을 캐시하는 CDN입니다. 주로 푸시할 수 있는 자산인 JS, 이미지 및 사용자 업로드에 사용됩니다.

이 둘은 서로 다르게 설정하고 관리자가 모두 설정하는 것을 권장합니다.

CDN을 사용하지 않거나(또는 버킷 URL을 CDN URL로 입력하는 경우) 문제가 발생할 가능성이 높으며 지원되지 않습니다.

다음 예시에서 https://falcoland-files-cdn.falco.dev는 버킷 내 파일을 서빙하도록 구성된 CDN입니다. 예시에서 버킷 이름은 falcoland-files로 설정되었습니다.

이 설정을 app.yml의 환경 변수로 구성하는 것이 권장됩니다. 이는 CDCK가 인프라에서 이렇게 하기 때문에 잘 테스트되었기 때문입니다. 또한, 자산을 업로드하는 작업은 자산이 컴파일된 후에 수행되며, 이는 리빌드(rebuild) 중에 발생합니다. 처음부터 Object Storage와 올바르게 작동하는 Discourse를 구동하려면 사이트가 시작되기 전에 자산이 업로드되도록 환경 변수를 설정해야 합니다.

아래 목록에서 제공업체를 선택하고 app.yml 파일의 env 섹션에 이러한 설정을 추가하되, 값을 적절히 조정하세요:

AWS S3

공식적으로 지원하고 내부적으로 사용하는 것입니다. 그들의 CDN 제공인 Cloudfront도 버킷 파일을 프론트할 수 있습니다. 권한을 올바르게 구성하는 방법은 Set up file and image uploads to S3 를 참조하세요.

  DISCOURSE_USE_S3: true
  DISCOURSE_S3_REGION: us-west-1
  DISCOURSE_S3_ACCESS_KEY_ID: myaccesskey
  DISCOURSE_S3_SECRET_ACCESS_KEY: mysecretkey
  DISCOURSE_S3_CDN_URL: https://falcoland-files-cdn.falco.dev
  DISCOURSE_S3_BUCKET: falcoland-files
  DISCOURSE_S3_BACKUP_BUCKET: falcoland-files/backups
  DISCOURSE_BACKUP_LOCATION: s3

Digital Ocean Spaces

DO 제공은 좋으며 그대로 작동합니다. 파일 목록 제한을 활성화해도 괜찮습니다. 유일한 문제는 그들의 CDN 제공이 아주 잘 깨져 있습니다는 것이며, 따라서 파일에는 다른 CDN을 사용해야 합니다. 또한, 리빌드 때마다 재설치되므로 CORS 규칙을 설치할 필요가 없습니다.

예시 설정:

  DISCOURSE_USE_S3: true
  DISCOURSE_S3_REGION: whatever
  DISCOURSE_S3_ENDPOINT: https://nyc3.digitaloceanspaces.com
  DISCOURSE_S3_ACCESS_KEY_ID: myaccesskey
  DISCOURSE_S3_SECRET_ACCESS_KEY: mysecretkey
  DISCOURSE_S3_CDN_URL: https://falcoland-files-cdn.falco.dev
  DISCOURSE_S3_BUCKET: falcoland-files
  DISCOURSE_S3_BACKUP_BUCKET: falcoland-files/backups
  DISCOURSE_BACKUP_LOCATION: s3
  DISCOURSE_S3_INSTALL_CORS_RULE: false 

Linode Object Storage

Linode에는 HTTP_CONTINUE_TIMEOUT이라는 추가 설정 매개변수가 필요합니다.

예시 설정:

  DISCOURSE_USE_S3: true
  DISCOURSE_S3_REGION: us-east-1
  DISCOURSE_S3_HTTP_CONTINUE_TIMEOUT: 0
  DISCOURSE_S3_ENDPOINT: https://us-east-1.linodeobjects.com
  DISCOURSE_S3_ACCESS_KEY_ID: myaccesskey
  DISCOURSE_S3_SECRET_ACCESS_KEY: mysecretkey
  DISCOURSE_S3_CDN_URL: https://falcoland-files-cdn.falco.dev
  DISCOURSE_S3_BUCKET: falcoland-files
  DISCOURSE_S3_BACKUP_BUCKET: falcoland-files/backup
  DISCOURSE_BACKUP_LOCATION: s3

Google Cloud Platform Storage

파일 목록 표시가 깨져 있으므로 자산이 작동하도록 이를 건너뛰기 위해 추가 ENV가 필요합니다. 또한 CORS를 건너뛰고 수동으로 구성하세요.

:warning: 파일 목록을 표시할 수 없으므로 백업 목록도 표시할 수 없으며, 자동 백업이 실패하므로 백업에 사용하는 것을 권장하지 않습니다. 그러나 일부는 Storage Legacy Object Owner에서 Storage Legacy Bucket Owner로 역할을 변경하면 백업이 올바르게 작동한다고 제안합니다. Google Cloud 관련 토론은 이 주제를 참조하세요.

통합을 더 잘 만들기 위한 서드파티 플러그인이 Discourse GCS Helper 에 있습니다.

예시 설정:

  DISCOURSE_USE_S3: true
  DISCOURSE_S3_REGION: us-east1
  DISCOURSE_S3_INSTALL_CORS_RULE: false
  FORCE_S3_UPLOADS: 1
  DISCOURSE_S3_ENDPOINT: https://storage.googleapis.com
  DISCOURSE_S3_ACCESS_KEY_ID: myaccesskey
  DISCOURSE_S3_SECRET_ACCESS_KEY: mysecretkey
  DISCOURSE_S3_CDN_URL: https://falcoland-files-cdn.falco.dev
  DISCOURSE_S3_BUCKET: falcoland-files
  #DISCOURSE_S3_BACKUP_BUCKET: falcoland-files/backup
  #DISCOURSE_BACKUP_LOCATION: s3

Scaleway Object Storage

Scaleway 제공도 매우 좋으며, 대부분 모든 것이 잘 작동합니다.

:warning: Scaleway 멀티파트 업로드는 최대 1,000개 부분만 지원합니다. 이는 최대 10,000개 부분을 지원하는 Amazon S3와 일치하지 않습니다. 더 큰 인스턴스의 경우, 이로 인해 Discourse 백업이 실패할 수 있으며 추가 시도를 하기 전에 미완료 업로드를 수동으로 삭제해야 할 수 있습니다. 작은 인스턴스의 경우 이는 문제가 되지 않습니다. Scaleway는 피드백에 상당히 개방적이므로, 이 제한 사항을 변경하고 싶다면 그들에게 연락해야 합니다.

DISCOURSE_S3_ENDPOINT 매개변수의 경우, Discourse는 전체 리전의 엔드포인트인 https://s3.{region}.scw.cloud를 사용합니다. Scaleway 대시보드에서 찾을 수 있는 "Bucket endpoint"는 https://{bucketName}.s3.{region}.scw.cloud 형식입니다. 연결 오류를 방지하려면 버킷 이름 서브도메인을 생략하세요.

예시 설정:

  DISCOURSE_USE_S3: true
  DISCOURSE_S3_REGION: fr-par
  DISCOURSE_S3_ENDPOINT: https://s3.fr-par.scw.cloud
  DISCOURSE_S3_ACCESS_KEY_ID: myaccesskey
  DISCOURSE_S3_SECRET_ACCESS_KEY: mysecretkey
  DISCOURSE_S3_CDN_URL: https://falcoland-files-cdn.falco.dev
  DISCOURSE_S3_BUCKET: falcoland-files
  DISCOURSE_S3_BACKUP_BUCKET: falcoland-files/backups
  DISCOURSE_BACKUP_LOCATION: s3

Vultr Object Storage

Vultr에는 HTTP_CONTINUE_TIMEOUT이라는 추가 설정 매개변수가 필요합니다.

예시 설정:

  DISCOURSE_USE_S3: true
  DISCOURSE_S3_REGION: whatever
  DISCOURSE_S3_HTTP_CONTINUE_TIMEOUT: 0
  DISCOURSE_S3_ENDPOINT: https://ewr1.vultrobjects.com
  DISCOURSE_S3_ACCESS_KEY_ID: myaccesskey
  DISCOURSE_S3_SECRET_ACCESS_KEY: mysecretkey
  DISCOURSE_S3_CDN_URL: https://falcoland-files-cdn.falco.dev
  DISCOURSE_S3_BUCKET: falcoland-files
  DISCOURSE_S3_BACKUP_BUCKET: falcoland-files/backup
  DISCOURSE_BACKUP_LOCATION: s3

Backblaze B2 Cloud Storage

CORS를 건너뛰고 수동으로 구성해야 합니다.

BackBlaze와 함께 clean up orphan uploads가 올바르게 작동하지 않는다는 보고가 있습니다. 고아 정리(orphan cleanup)가 작동하려면 버킷에 대한 라이프사이클 규칙을 변경해야 합니다.

예시 설정:

  DISCOURSE_USE_S3: true
  DISCOURSE_S3_REGION: "us-west-002"
  DISCOURSE_S3_INSTALL_CORS_RULE: false
  DISCOURSE_S3_CONFIGURE_TOMBSTONE_POLICY: false
  DISCOURSE_S3_ENDPOINT: https://s3.us-west-002.backblazeb2.com
  DISCOURSE_S3_ACCESS_KEY_ID: myaccesskey
  DISCOURSE_S3_SECRET_ACCESS_KEY: mysecretkey
  DISCOURSE_S3_CDN_URL: https://falcoland-files-cdn.falco.dev
  DISCOURSE_S3_BUCKET: falcoland-files
  DISCOURSE_S3_BACKUP_BUCKET: falcoland-files/backup
  DISCOURSE_BACKUP_LOCATION: s3

참고: B2로의 초기 마이그레이션 중에 일일 2,500회 무료 클래스 C 트랜잭션 제한에 도달할 수 있습니다. 한도를 제거하려면 결제 수단을 추가해야 합니다.

MinIO Storage Server

S3 대안으로 MinIO 저장 서버를 사용하기 전에 충족해야 하는 몇 가지 주의사항과 요구 사항이 있습니다:

  1. 완전히 구성된 MinIO 서버 인스턴스가 있어야 합니다.
  2. 도메인 기반 버킷 URL을 위해 MinIO 구성에서 Domain Support가 활성화되어 있어야 합니다. 이것은 MinIO와 Discourse에 대한 필수 설정 요구 사항입니다. MinIO는 더 이상 Discourse에서 지원되지 않는 레거시 S3 “path” 스타일을 여전히 지원하기 때문입니다.
  3. 버킷 서브도메인이 MinIO 서버로 올바르게 해석되도록 MinIO에 대한 DNS 구성이 올바르게 설정되어 있어야 하며, MinIO 서버는 기본 도메인(이 경우 minio.example.com)으로 구성되어야 합니다.
  4. discourse-data 버킷이 MinIO 서버에 존재하고 “public” 정책이 설정되어 있어야 합니다.
  5. 이 문서의 앞부분에서 설명한 대로, 버킷으로 가리키고 요청을 캐시하는 올바르게 구성된 CDN으로 가리키는 S3 CDN URL이 있어야 합니다.
  6. CDN이 데이터를 가져올 때 실제 “Host” 헤더로 코어 S3 URL을 사용하도록 구성되어야 합니다. 예를 들어, discourse-data.minio.example.com - 그렇지 않으면 CORB 문제를 일으킬 수 있습니다.

위 주의사항과 전제 조건이 충족된다고 가정하면, 예시 설정은 다음과 같은 형태가 될 것입니다:

  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
  DISCOURSE_S3_INSTALL_CORS_RULE: false

앱 리빌더가 규칙을 설치하지 않더라도 MinIO에서 CORS는 여전히 활성화됩니다. 기본적으로, MinIO에서 모든 HTTP 동사에 대해 CORS가 활성화되어 있으며, 결과적으로 MinIO는 BucketCORS(S3 API)를 지원하지 않습니다.

Azure Blob Storage with Flexify.IO

Azure Blob Storage는 S3 호환 서비스가 아니므로 Discourse와 함께 사용할 수 없습니다. 플러그인은 있지만 깨져 있습니다.

Azure Blob Storage에 S3 호환 인터페이스를 노출하는 가장 쉬운 방법은 Azure Storage 프로토콜을 S3로 _변환_하는 Flexify.IO 서버를 추가하는 것입니다.

이 글 작성 시점 기준으로, 이 서비스는 Azure에서 무료이며, 실행을 시작하려면 매우 기본적(저가)인 VM 티어만 필요합니다. 그러나 설정이 약간 필요합니다.

  1. Azure 포털에서 Flexify.IO - Amazon S3 API for Azure Blob Storage라는 새 리소스를 생성합니다.
  2. 가벼운 사용의 경우, 최소 VM 구성이 잘 작동하는 것 같습니다. 대부분의 기본 구성을 받아들여도 됩니다. VM을 생성할 때 PEM 키 파일을 저장하는 것을 잊지 마세요.
  3. Flexify.IO VM 링크로 이동하여 시스템에 들어갑니다. Azure Blob Storage 데이터 제공자 및 생성된 S3 엔드포인트를 설정하는 방법에 대한 지시를 따르세요. 엔드포인트 설정인 Public read access to all objects in virtual buckets가 true인지 확인하세요. S3 엔드포인트 URL과 키를 복사합니다.
  4. New Virtual Bucket을 눌러 가상 버킷을 생성합니다. Azure Blob Storage 컨테이너와 같은 이름이거나 다른 이름일 수 있습니다. 이 가상 버킷으로 병합할 컨테이너를 연결합니다. 이 가상 버킷은 S3를 통해 공개적으로 읽을 수 있는 버킷을 노출하는 데 사용됩니다.
  5. 기본적으로 Flexify.IO는 자체 서명된 SSL 인증서를 설치하지만, S3 엔드포인트에는 HTTPS가 필요합니다. 키 파일(기본 사용자 이름은 azureuser임)을 사용하여 VM에 SSH로 로그인하고, 다음 파일을 올바른 파일로 교체합니다:
  • /etc/flexify/ssl/cert.pem - 인증서 파일(PEM 인코딩)로 교체

  • /etc/flexify/ssl/key.pem - 개인 키 파일(PKCS#8 PEM 인코딩, BEGIN PRIVATE KEY로 시작하고 PKCS#1인 BEGIN RSA PRIVATE KEY로 시작하지 않는 것)로 교체

    이 파일들은 root 소유이므로 교체하려면 sudo가 필요합니다. 교체된 파일이 원래 파일과 동일한 소유권과 권한(root:root600 권한)을 갖도록 하는 것이 가장 좋습니다.

  1. 기본적으로 Flexify.IO는 여러 버킷을 가진 루트 수준의 S3 서비스를 생성합니다. Discourse는 버킷에 대해 서브도메인 지원을 요구합니다. <your Flexify.IO VM IP>/flexify-io/manage/admin/engines/configs/1로 이동하면 숨겨진 구성 페이지가 열립니다!
  2. Endpoint hostname 필드에 S3 기본 도메인(예: s3.mydomain.com)을 지정합니다. 이 필드는 기본적으로 비어 있을 것입니다. Save를 눌러 설정을 저장합니다.
  3. Azure 포털에서 Flexify.IO VM을 재시작합니다.
  4. DNS에서 s3.mydomain.com*.s3.mydomain.comFlexify.IO VM IP로 매핑합니다.
  5. Discourse에서 관리 페이지에 다음을 설정합니다(예, 설정을 app.yml에 둘 필요가 없습니다):
use s3: true
s3 region: anything
s3 endpoint: https://s3.mydomain.com
s3 access key: myaccesskey
s3 secret assess key: mysecret key
s3 cdn url: https://<azure-blob-account>.blob.core.windows.net/<container>
s3 bucket: <virtual bucket>
s3 backup bucket: <backup bucket>  (공개 읽기 액세스가 필요하지 않고 Flexify.IO가 자동으로 노출하므로 어떤 컨테이너든 괜찮습니다)
backup location: s3

프로덕션과 스테이징에 동일한 버킷을 사용하는 것은 권장되지 않습니다. 그래도 그렇게 하려면, 스테이징 사이트가 프로덕션 자산을 삭제하지 않도록 조치를 취해야 합니다(최소한 s3 disable cleanup을 설정하고, 프로덕션 백업이 삭제되는지 주의하세요).

Wasabi

@pfaffman은 백업에 wasabi를 시도했지만, 간헐적이고 조용히 실패하는 것 같았고, 백업이 하드 드라이브에 남아 결국 디스크를 가득 채웠습니다. wasabi도 meta도 단서를 찾지 못했으므로, 권장하지 않지만 결과는 다를 수 있습니다. @pfaffman은 이 문제가 백업과 자동 재부팅이 어떻게든 동시에 예약된 때문이라고 확신합니다. 백업에만 사용되었지만 잘 작동하는 것 같았습니다. 누군가가 시도해 보고 여기에 보고한다면, 적어도 백업에는 작동해야 합니다.

Oracle Cloud

Oracle Cloud는 버킷에 대한 가상 호스트 스타일 액세스를 지원하지 않으며 작동하지 않습니다

Cloudflare R2

Cloudflare R2는 Cloudflare CDN을 사용할 때 S3 object storage와 호환됩니다. Cloudflare의 무료 플랜은 10GB의 저장소를 제공합니다 이는 대부분의 포럼의 필요보다 훨씬 많을 것입니다.

Cloudflare R2를 구성하려면, Cloudflare 대시보드의 R2 Object Storage에서 관련 설정을 구성해야 합니다.

요구 사항(업로드 또는 백업 또는 둘 다)에 따라, app.yml 파일이나 Admin-All site settings에서 S3을 검색하여 삽입해야 하는 관련 설정은 다음과 같습니다:

  DISCOURSE_ENABLE_S3_UPLOADS: true
  DISCOURSE_S3_REGION: auto
  DISCOURSE_S3_ENDPOINT: https://<your-account-id>.r2.cloudflarestorage.com
  DISCOURSE_S3_ACCESS_KEY_ID: "xxx"
  DISCOURSE_S3_SECRET_ACCESS_KEY: "xxx"
  DISCOURSE_S3_UPLOAD_BUCKET: your-upload-bucket-name
  DISCOURSE_S3_CDN_URL: https://uploads.yourdomain.com
# DISCOURSE_S3_USE_CDN_URL_FOR_ALL_UPLOADS: true

  DISCOURSE_ENABLE_DIRECT_S3_UPLOADS: true
  DISCOURSE_S3_USE_ACLS: false
  
  DISCOURSE_BACKUP_LOCATION: s3
  DISCOURSE_S3_BACKUP_BUCKET: your-backup-bucket-name

app.yml을 편집하고 싶지 않다면, 관리 UI에서 이렇게 할 수 있습니다:

“Admin → All site settings” (S3 검색):

  • Enable S3 uploads = true
  • Enable direct S3 uploads = true
  • S3 access key ID = "xxx"
  • S3 secret access key = "xxx"
  • S3 region = any
  • S3 upload bucket = your upload bucket name
  • S3 endpoint = https://<your-account-id>.r2.cloudflarestorage.com
  • S3 CDN URL = https://uploads.yourdomain.com
  • S3 use ACLs = false (이것을 비활성화하세요!)
  • S3 backup bucket = your backup bucket name
  • Backup location = S3

Cloudflare R2 구성 시 중요한 참고 사항:

  1. Cloudflare R2를 위해 app.yml 또는 web_only.yml을 구성할 때, 오직 DISCOURSE_S3_CDN_URL만 설정하세요. DISCOURSE_CDN_URL은 설정하지 마세요. Cloudflare를 통해 메인 도메인을 프록시하고 있다면, 이미 자동으로 앱 자산을 캐시하고 서빙하고 있습니다. Cloudflare DNS를 사용하여 별도의 DISCOURSE_CDN_URL을 구성하려고 하면, Discourse의 엄격한 NGINX 호스트 라우팅이 요청을 거부하여 무한한 301 리디렉트 루프, CORS 정책 차단 및 깨진 사이트를 초래합니다.
  • DISCOURSE_CDN_URL은 주석 처리된 상태로 두세요.
  • DISCOURSE_S3_CDN_URL: https://your-r2-custom-domain.com을 설정하세요.
  1. API 토큰 권한: Discourse에는 자격 증명 필드가 한 세트만 있으므로, Cloudflare에서 생성하는 API 토큰은 업로드 버킷과 백업 버킷 모두에 액세스할 수 있는 권한이 있어야 합니다. 토큰을 생성할 때, "Apply to all buckets"를 선택하거나 "Apply to specific buckets"를 사용하여 둘 다 확인되어 있는지 확인하세요. 또한, API 키를 생성할 때 Object Read & Write를 확인하세요(기본값은 Object Read only만 있음).

  2. Cloudflare에서 엔드포인트 URL을 복사할 때, URL 끝에 버킷 이름이 추가될 수 있습니다 - 붙여넣기되면 .yml 파일(또는 관리 설정)의 문자열 끝에서 버킷 이름을 삭제해야 합니다.

  3. PDFZIP 파일을 포함한 모든 업로드에 R2 업로드 버킷을 사용하려면 # DISCOURSE_S3_USE_CDN_URL_FOR_ALL_UPLOADS: true의 주석을 해제하세요. (이 경우 모든 업로드된 파일이 직접 링크를 통해 공개적으로 사용 가능해집니다)

  4. DISCOURSE_ENABLE_DIRECT_S3_UPLOADS(true)를 활성화하는 경우 DISCOURSE_S3_USE_ACLS(false)를 비활성화해야 합니다. 이는 Cloudflare R2가 버킷 수준 권한을 사용하기 때문이며, 업로드 버킷은 공개적이고 백업 버킷은 비공개여야 합니다. Cloudflare R2 업로드의 경우, 버킷 권한을 설정할 때 Cloudflare 대시보드에서 구성하므로 CORS 규칙 rake 작업을 구성하거나 IAM json을 작성할 필요가 없습니다. Cloudflare의 “Object Read & Write” 토큰은 자동으로 멀티파트 업로드 권한을 부여하며, 다음 CORS 규칙을 Cloudflare 대시보드의 R2 업로드 버킷 설정의 CORS Policy 아래에 직접 붙여넣으면 rake 작업이 필요 없습니다.

[
  {
    "AllowedOrigins": [
      "https://forum.yourdomain.com"
    ],
    "AllowedMethods": [
      "GET",
      "PUT",
      "POST",
      "DELETE",
      "HEAD"
    ],
    "AllowedHeaders": [
      "*"
    ],
    "ExposeHeaders": [
      "ETag"
    ],
    "MaxAgeSeconds": 3000
  }
]

Cloudflare 설정에 대한 더 많은 정보는 이 주제도 참조하세요: Using Discourse with Cloudflare: Best Practices

Contabo

@tuxed는 S3 호환 업로드에 Contabo Object Storage를 작동시키려 시도했습니다. 업로드 시 URL에 저장소 이름이 접두사로 추가되는 것 같으며, 작동하게 만들지 못했습니다.

보안 업로드

보안 업로드는 AWS S3에서만 지원됩니다. rake uploads:migrate_to_s3가 실패하면, 보안이 필요하지 않다는 것을 알고 있다면, 먼저 계수하고 그런 다음 해당 업로드를 비보안으로 표시하기 위해 다음 명령을 입력해야 합니다. 이 경우 AWS S3를 사용해야 합니다.

./launcher enter app
rails c
Upload.where(secure: true).count
Upload.where(secure: true).update_all(secure:false)

  1. Oracle Cloud는 버킷에 대한 가상 호스트 스타일 액세스를 지원하지 않으며 작동하지 않습니다 ↩︎

70개의 좋아요
Defining DISCOURSE_S3_CDN_URL links to assets in S3 CDN URL
Backblaze S3 issue: duplicated uploads after delete
Migrate from AWS to Digital Ocean with 2 containers, spaces and 2 CDNs
Using Scaleway s3-compatible object storage
Extend S3 configuration for other s3 API compatible cloud storage solutions
Setting up backup and image uploads to Backblaze B2
Upload assets to S3 after in-browser upgrade
What are the right settings to use S3 bucket (with non-Amazon URL)?
Using multiple containers - what needs to be shared?
Virus scanning of uploaded files
Imgur images broken
Admin role conflates server admin and board admin
Error in rebuilding using minio as object store
Use WebTorrent to load media objects
Issues with changing File/Image upload location to S3 Server from local storage
Hosting Optimization with Digital Ocean
Hosting Optimization with Digital Ocean
Theme modifiers: A brief introduction
Configure automatic backups for Discourse
Problem with Backblaze for backup- Failed to list backups from S3: Signature validation failed
Move from BackBlaze B2 to Digital Ocean Spaces
Which free storage for many images? also to be used for thumbnails etc
Migrate from AWS to Digital Ocean with 2 containers, spaces and 2 CDNs
Restore Failure - S3 (compatible) backup
Restore Failure - S3 (compatible) backup
Digitalocean block storage VS amazon S3
Digitalocean block storage VS amazon S3
Admin upgrade page doesn't load with a CDN
Install Discourse for Production Environment on Windows Server
Running Discourse on Azure Web Sites vs. Azure VM?
How to turn off S3 storage?
Access Denied error message when trying to upload images
What are the right settings to use S3 bucket (with non-Amazon URL)?
REQ: Support S3 backup to a service like Backblaze
REQ: Support S3 backup to a service like Backblaze
Using Scaleway s3-compatible object storage
Overwrite meta og:image image source to use externally public loaded images on topics?
How to store uploads with multiple web_only servers?
Can not edit topics with picture with S3 backend
Finding UI generated backup and restoring site
Looking for doc to connect discourse with digital ocean spaces
Looking for doc to connect discourse with digital ocean spaces
Looking for doc to connect discourse with digital ocean spaces
403 Error with digital ocean cdn
Link to headers (anchor links)
NoMethodError downcase s3_bucket_name absolute_base_url
What should I enter in the S3 CDN settings if I don't have a CDN?
Backing up files in Object Storage
Minio: A header you provided implies S3 functionality that is not implemented
Configure automatic backups for Discourse
S3 OVH Object Storage
File directory system
Unable to backup or navigate to backups
Uploads to AWS S3 and Configured CDN
Migration to a Self-Hosted solution from Kubernetes
How to develop discourse in a team?
Images didn't load after configuring S3 uploads
Need Azure blob storage
Use Google Cloud Storage Instead of S3
Move discourse uploads to free space on server
Strange behavior with Digital Ocean Spaces/S3 and lots of duplicated CORS rules for `example.com`
Can't upload PDF to S3
"canned acl" error when uploading images
AWS S3 Object Ownership
What’s your server configurations?
How to debug S3 uploads
Problems with Patreon Login, Force HTTPS, and S3 CDN (three) Issues
Cron task to sync local backups to DigitalOcean Spaces
Cron task to sync local backups to DigitalOcean Spaces
Problems with Patreon Login, Force HTTPS, and S3 CDN (three) Issues
Help restoring - system hung at midnight
Help restoring - system hung at midnight
Image upload error: The bucket does not allow ACL's
Make s3_region a string value
How can I set s3_force_path to true?
S3 assets folder, is a cleanup needed?
BunnyCDN storage for automatic backups
BunnyCDN storage for automatic backups
Move Uploads and Backups to DigitalOcean Block Storage
Required local storage for URL referenced images vs. uploaded images?
Colored loading dots because assets not uploaded
Is DO Spaces CDN still broken? Any workarounds?
Is DO Spaces CDN still broken? Any workarounds?
Is DO Spaces CDN still broken? Any workarounds?
Basic How-To for Using MinIO storage server run by you for your Discourse Instance
Minio instead of S3?
Configure automatic backups for Discourse
S3 image bandwidth costs are getting annoying
S3 image bandwidth costs are getting annoying
Support for ImgBB image upload service
Install Discourse on Amazon Web Services (AWS)
Account creation not working with discourse_encrypt
Cannot load any images “Uncaught (in promise) no-response: no-response”
Tips on Google Cloud S3
Enable a CDN for your Discourse
Invalid URL for markdown-it-bundle
Not using volumes (or automatically using S3) when hosting with Docker
Configuring automatic backups
I have a problem with my proxy status
Inline PDF Previews
My images are not working
Getting error 422 invalid argument when configure S3 upload with GCS
SSL_connect returned=1 errno=0 peeraddr=162.243.189.2:443 state=error: certificate verify failed (Hostname mismatch)
SSL_connect returned=1 errno=0 peeraddr=162.243.189.2:443 state=error: certificate verify failed (Hostname mismatch)
Strange behavior with Digital Ocean Spaces/S3 and lots of duplicated CORS rules for `example.com`
My install broke after updating, how can I fix it?
Uploads Subdomain For Cloudflare
Hetzner deleted my account, my server and I was left with nothing. What to do?
SSL_connect returned=1 errno=0 peeraddr=162.243.189.2:443 state=error: certificate verify failed (Hostname mismatch)
SSL_connect returned=1 errno=0 peeraddr=162.243.189.2:443 state=error: certificate verify failed (Hostname mismatch)
SSL_connect returned=1 errno=0 peeraddr=162.243.189.2:443 state=error: certificate verify failed (Hostname mismatch)
SSL_connect returned=1 errno=0 peeraddr=162.243.189.2:443 state=error: certificate verify failed (Hostname mismatch)
SSL_connect returned=1 errno=0 peeraddr=162.243.189.2:443 state=error: certificate verify failed (Hostname mismatch)
Understanding Uploads, Images, and Attachments
S3, Assets & CDN Error
Capacity planning / Resource requirements
Migrate assets to s3 rake tasks
Best option for DB and file Storage
S3 error, when updating to 2.9.0.beta1
Forum rendered unusable
Forum rendered unusable
Configure automatic backups for Discourse
Migrate Discourse broke S3 images
Configure automatic backups for Discourse
Cloud storage and cdn
Migrating uploads from S3 to local
Another discourse offline "bootstrap failed with exit code 5"
Another discourse offline "bootstrap failed with exit code 5"
AI Plugin Build Error - 'bundle exec rake db:migrate' failed
Your Docker installation is not working correctly - no space left on device - safe to use ./launcher cleanup?
Uncaught SyntaxError: forum spins nonstop and never loads
Why is my upload limit 100mb?It's set to 500mb
Trouble with Google Bucket for backup
Did I overwrite my site settings with a cross-instance backup/restore?
Need tips on making my forum faster
What should be the server requirements
SSL_connect returned=1 errno=0 peeraddr=162.243.189.2:443 state=error: certificate verify failed (Hostname mismatch)
Set up BackBlaze S3 with BunnyCDN
Why you should use Discourse internally for your company/team instead of Slack (4 years use case)
Make s3_region a string value
Imgur upload built into the post buttons
Decoupled Discourse Application - Managed Redis, Managed Postgres, and DIgital Ocean Volume with Discourse
S3 and Cloudfront - Setup Not Working
Cannot upload images in mobile discourse
Cloudflare R2: Navigating Setup and Handling Configuration Errors
Cloudflare R2: Navigating Setup and Handling Configuration Errors
Cloudflare R2: Navigating Setup and Handling Configuration Errors
S3 assets broken after moving forum
Backup request via FTP
Error when doing "bundle exec rake s3:upload_assets" - Could not locate Gemfile or .bundle/ directory
Separate S3 access keys for backups and uploads?
Topic List Previews (legacy)
Disk usage spike during backup, Discourse crashed hard :-(
Make s3_region a string value
Favicon setup: "To work correctly over a CDN it must be a png"
Change image folder to symlinked folder
Migrating uploads from S3 to local
S3 Upload Confusion: Dashboard vs. app.yml
Old installation failing upgrade
Where are Images and uploads stored?
Rebuild issue: [Cannot set dual-stack in combination with a custom endpoint.]
Problem updating data in the separate database
Resizing images off server
Unable to setup S3 bucket
Discourse Stuck on Loading (Logs)
Discourse Stuck on Loading (Logs)
Unable to setup S3 bucket
How to add AWS Cloudfront as a Discourse CDN
Unable to setup S3 bucket
Configured s3, but i want asset to serve locally
Configured s3, but i want asset to serve locally
Set up BackBlaze S3 with BunnyCDN
Discourse s3 backup folder
SSO broken after rebuild with stable v3.3.3
How to Configure Cloudflare R2 for your Discourse Community
如何批量修改文件链接地址
Can't migrate uploads to S3
Backup discourse from the command line
Stuck and lost updating forum, problems with PG migration
Can't rebuild due to AWS SDK gem bump and new AWS Data Integrity Protections
Can't rebuild due to AWS SDK gem bump and new AWS Data Integrity Protections
S3 (not AWS) backups stopped working, presumably since an update
Troubleshooting S3 Uploads: Site hangs after rebuild, JS assets fail to load with net::ERR_... on both R2 and GCS
Inquiry About Discourse’s Support for Amazon S3 Storage
Backup discourse from the command line
Inquiry About Discourse’s Support for Amazon S3 Storage
Inquiry About Discourse’s Support for Amazon S3 Storage
Cloudflare R2 Storage Issues
Hetzner S3 support
Can the /var/discourse and /var/lib/docker folders be on different volumes?
An AWS S3 Integration with Discourse Tutorial would be nice
Issues with AWS CDN and S3
Setting up backup and image uploads to Backblaze B2
Issues with AWS CDN and S3
Digital Ocean Spaces (S3) "unable to sign request without credentials set"
Digital Ocean Spaces (S3) "unable to sign request without credentials set"
Digital Ocean Spaces (S3) "unable to sign request without credentials set"
Digital Ocean Spaces (S3) "unable to sign request without credentials set"
为啥我的七牛云s3附件上传成功后,论坛中无法加载出来?
Install Discourse on a residential internet with Cloudflare Tunnel
Custom emoji don't use CDN for S3 stored assets in a few pages
S3 and Cloudfront - Setup Not Working
Secure Uploads
Make s3_region a string value
Backup Files Not Showing in Discourse Backend After Uploading to Cloudflare R2
Images after a restore don't have S3 bucket URL
Can't upload to S3 (Cloudflare R2)
Daily Summary (9pm UTC)
Custom Emojis loaded from S3/R2 bypass CDN routing
Confused about Self Hosting
I can't upload photo after setting Cloudflare R2
Hash/anchors are being stripped from URLs on mobile. How to stop that?
Digital Ocean Spaces (S3) "unable to sign request without credentials set"
Is Scaleway a good option for object storage?
Blackblaze&Cloudflare: image uploading works, but not showing in post
SMF2 Conversion and Rake to S3 Help
Backing up your forum
What causes rake uploads:fix_relative_upload_links
Running 2 hosts behind haproxy fails with random 404s
Site Blank After Rebuild
Rebuild goes into a loop
Custom Emojis loaded from S3/R2 bypass CDN routing
Backblaze S3 issue: duplicated uploads after delete
Migrate_to_S3 Fails on Rebake
Downloads coming from S3 even with DISCOURSE_S3_CDN_URL set
Errors trying to use custom S3 storage
Moving from one S3 bucket to another
S3 image bandwidth costs are getting annoying
Basic How-To for Using MinIO storage server run by you for your Discourse Instance
SSL error - can't upload images
Digital Ocean Spaces don’t implement the AWS S3 API for the CORS rule
Extend S3 configuration for other S3 API compatible services
How to separate uploaded files to another server
Storing Images in the cloud
S3 and Cloudfront - Setup Not Working
Migrate_to_S3 Fails on Rebake
Can not access backup page and related error when restoring using GCP Object Storage
Cannot rebake after setting up CDN
Rebuild failure - skipping "after_assets_precompile" section of app.yml
High Availability 3 Server setup
Enable hidden setting to include S3 uploads in the backups
Run Discourse as docker swarm service
Azure Blob Storage Plugin
How might we better structure #howto?
Migrating uploaded files from DO to S3
Discourse as a closed wiki

Hi everyone,

I’ve been using S3 storage for a number of years now without a CDN.

Following the advice given to me in another thread I have today setup CloudFront CDN.

Before I add the CDN URL to my control panel and rebake 230,000+ posts only to find out I’ve got a CloudFront setting wrong and break everything, can someone confirm this is the expected behaviour for me please? :bowing_man:t2:

Currently, this is an example URL that for an image that a user has uploaded:

https://greyarrows.s3.dualstack.eu-west-2.amazonaws.com/original/3X/8/3/8335cab232f512f4a979c7f0c8562e149c01b212.png

Which displays:

My CloudFront “Domain Name” is: d1q8cepst0v8xp.cloudfront.net

If I manually edit my example URL above and replace the existing S3 part of the domain name with the domain name of my CloudFront domain name, I get:

https://d1q8cepst0v8xp.cloudfront.net/original/3X/8/3/8335cab232f512f4a979c7f0c8562e149c01b212.png

And sure enough, the image still loads correctly:

Therefore, am I correct in thinking I simply need to add a S3 CDN URL of d1q8cepst0v8xp.cloudfront.net` to my Discourse control panel, rebake all posts and just sit back and wait of the magic to happen?

Thanks in advance, CDN is all new to me and I don’t have a development environment in which to safely test this :grimacing:

4개의 좋아요

I also have the s3 configure tombstone policy setting enabled:

Screen Shot 2021-02-14 at 21.08.39

Will this be an issue? As I’m now using a CDN instead? Or are things in the background still checking the original S3 bucket, rather than a CDN URL?

I’m naturally thinking the latter, but again I can’t afford to kill of hundreds of thousands of my users photo uploads :scream:

:blush:

2개의 좋아요

The answer is yes.

To test this theory, before rebaking hundreds of thousands of posts, I did the following sanity checks:

  • Uploaded an image
  • Changed the S3 CDN URL setting
  • Rebuilt the HTML on my test post (via the UI)
  • Refreshed the page in the browser
  • Checked the Network tab of the browser console to confirm the image was being pulled via cloudfront
  • Uploaded a new test image to a new post
  • Checked the Network tab of the browser console to confirm the image was being pulled via cloudfront

I’m now rebaking all posts as we speak :+1:t2:

14개의 좋아요

Thanks for the report Richie. I also have had AWS S3 image storage running for several years and came to this post via the console message. But the description at the top doesn’t say anything about the case that you already had S3 and just need a CDN.

For the record here is what I did:

  1. Went to AWS console, under Network and Content Delivery picked Cloudfront
  2. Clicked the Create distribution button
  3. Filled out the fairly obvious form, the only thing you really need to do on it is to pick your AWS S3 bucket where the images are from the drop-down menu.
  4. Waited a bit for the Cloudfront configuration to finish..
  5. A <gibberish>.cloudfront.net domain showed up in the “Domain Name” column of the Cloudfront Distributions list.
  6. I copied and pasted that domain into the s3 cdn url field in my site admin File settings.
  7. I did some tests:
    a. I made a new post with an image upload and indeed it was on cloudfront.
    b. I hit Rebuild HTML on some random existing image posts and saw they also rebuilt with cloudfront.net images.
  8. Since all looked good I went in and ran a rebake, which took several hours as I have around half a million posts now:
./launcher enter app
# rake posts:rebake
  1. All seems to be working fine. It put a ton of jobs in the sidekiq queue, one per post it looks like, which are going to take a few days to clear but it is chunking though them now.
18개의 좋아요

Are you sure that is the case? This site here uses assets from CDN and we didn’t have to purge the cache. It’s also a EmberCli change that shouldn’t affect production :thinking:

5개의 좋아요

Oh those damn optimizers. I would tell you to disable that if possible as Discourse already ships optimal configurations for each asset. Those optimizers are great when you are hosting a black box web software from the 2000’s, but they fail hard on modern stuff. Also even the big name optimizer from Cloudflare often breaks Discourse, so I have no hopes for others. They may work one day, and break the next and all your visitors are left with a blank page. All that for zero benefits.

6개의 좋아요

Any chance you enabled secure_uploads in the site settings?

Also looks like this was reported and fixed today because of Discourse compatibility :

https://github.com/minio/minio/issues/12320

https://github.com/minio/minio/pull/12321

6개의 좋아요

Is there a way to disable this warning from showing up on my admin dashboard?

The server is configured to upload files to S3, but there is no S3 CDN configured.

I had issues setting up an S3 CDN, but it doesn’t cost me an arm and a leg so I am fine with just using S3 directly. But what I’d love to see is for this notification to go away because I am fully aware of the consequences.

2개의 좋아요

Hi.

I just want give update. We will able setup backup using GCS now. I post on other thread too. I hope it will help other people who painful search this solution.

How to do that?
Enable default config for backup(or you can setting form admin dashboard).

DISCOURSE_S3_BACKUP_BUCKET: falcoland-files/backup
DISCOURSE_BACKUP_LOCATION: s3

Then set bucket permission as Storage Legacy Object Owner:

  1. Go to your project in Google Cloud Console
  2. Select Storage
  3. Select your bucket
  4. Go to the permissions tab
  5. Add new permission, fill your service account email with your account. for roles, select Storage Legacy Object Owner
  6. Save and done.

Sorry for double post, I just want share this good update.
Thank you

5개의 좋아요

It’d be great if you could add Wasabi as well…

1개의 좋아요

I used wasabi for backups for a while. As far as configuration goes, it “just worked”, so you could give it a try if you want.

But with some frequency the backups failed silently and backups stayed on the local machine, filling up the disk. I looked at wasabi and Discourse errors and never found an explanation that would make it possible for either end to “fix” anything.

I don’t recommend it, as I’m not sure that it’s “great.”

2개의 좋아요

Thanks!
I will check how it goes this time.
The default backup frequency is 7 days between backups and up to 5 backups.
I’ll share how it goes.

1개의 좋아요

I was doing daily backups; I don’t remember how many I was trying to keep, but the local hard drive had room for only a couple.

2개의 좋아요

Which storage would you personally recommend?
I don’t think AWS and Azure are affordable for personal projects.
Not sure about Azure, but AWS looks confusing and unpredictable…

1개의 좋아요

I hoped that wasabi would be good for backups at least. Backblaze s3 is affordable. I don’t think I’ve used it for uploads, but it works for backups (I think). I think the only issue with backblaze is that (when I last tested it) you had to use a global key (so I couldn’t use it for clients who could see the key). I think someone recently posted a fix for that (something about “legacy” something, somewhere). For a personal project, that’s what I’d try next, I think. (And if you’re on Digital Ocean, spaces is OK, I think.)

3개의 좋아요

I’m on DO, but cost-wise Blackblaze/Wasabi is cheaper.
What did you use for uploads?

1개의 좋아요

Sorry, I can’t get.
Why do we have to specify settings in app.yml, as we can enter this information within from Discourse->Settings ?

1개의 좋아요

Because of the way that it handles building assets when the container is built, I think. It is quite confusing that the behavior is different when the settings are in the environment variables and the database, but that’s the way it works. It’s also a better way too handle them, as it means you can build and restore a new site from the command line.

4개의 좋아요

Where should I set this? I’m not finding it in Discourse admin settings?

1개의 좋아요