그 줄은 들여쓰기가 올바르지 않습니다. after_code와 정확히 2공백 들여쓰기가 되어야 합니다.
모두 문제없어 보입니다. 제가 물어본 after_assets_precompile 부분은 어떤가요?
“after_assets_precompile” 앞에 두 칸의 공백을 삽입해야 합니다.
해당 사항을 진행한 후 알려드리겠습니다. 시간을 내어 주셔서 정말 감사합니다 <3
이것을 적용하면 다음과 같은 오류가 발생하고 사이트가 로드되지 않으며, 사이트에 도달할 수 없습니다:
FAILED
--------------------
Pups::ExecError: cd /var/www/discourse && sudo -E -u discourse bundle exec rake s3:upload_assets failed with return #<Process::Status: pid 4803 exit 1>
Location of failure: /usr/local/lib/ruby/gems/3.2.0/gems/pups-1.2.1/lib/pups/exec_command.rb:132:in `spawn'
exec failed with the params {"cd"=>"$home", "cmd"=>["sudo -E -u discourse bundle exec rake s3:upload_assets", "sudo -E -u discourse bundle exec rake s3:expire_missing_assets"]}
bootstrap failed with exit code 1
** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one.
./discourse-doctor may help diagnose the problem.
./discourse-doctor를 실행한 후 다시 컴파일했지만 동일한 오류가 발생했습니다.
컨테이너에 진입하여 다음 코드를 실행하면 오류가 발생합니다:
rake uploads:migrate_to_s3
오류:
rake uploads:migrate_to_s3 --trace
Plugin name is 'DiscourseMatheditor', but plugin directory is named 'discourse-matheditor'
Plugin name is 'discourse-post-voting', but plugin directory is named 'discourse-question-answer'
Plugin name is 'discourse-topic-voting', but plugin directory is named 'discourse-voting'
** Invoke uploads:migrate_to_s3 (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute uploads:migrate_to_s3
Please note that migrating to S3 is currently not reversible!
[CTRL+c] to cancel, [ENTER] to continue
Migrating uploads to S3 for 'default'...
Some uploads were not migrated to the new scheme. Running the migration, this may take a while...
rake aborted!
FileStore::ToS3MigrationError: Some uploads could not be migrated to the new scheme. You need to fix this manually. (FileStore::ToS3MigrationError)
/var/www/discourse/lib/file_store/to_s3_migration.rb:156:in `migrate_to_s3'
/var/www/discourse/lib/file_store/to_s3_migration.rb:59:in `migrate'
/var/www/discourse/lib/tasks/uploads.rake:126:in `migrate_to_s3'
/var/www/discourse/lib/tasks/uploads.rake:106:in `block in migrate_to_s3_all_sites'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rails_multisite-6.0.0/lib/rails_multisite/connection_management/null_instance.rb:49:in `with_connection'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rails_multisite-6.0.0/lib/rails_multisite/connection_management/null_instance.rb:36:in `each_connection'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rails_multisite-6.0.0/lib/rails_multisite/connection_management.rb:21:in `each_connection'
/var/www/discourse/lib/tasks/uploads.rake:104:in `migrate_to_s3_all_sites'
/var/www/discourse/lib/tasks/uploads.rake:100:in `block in <main>'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/task.rb:281:in `block in execute'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/task.rb:281:in `each'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/task.rb:281:in `execute'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/task.rb:199:in `synchronize'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/task.rb:199:in `invoke_with_call_chain'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/task.rb:188:in `invoke'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/application.rb:188:in `invoke_task'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/application.rb:138:in `block (2 levels) in top_level'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/application.rb:138:in `each'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/application.rb:138:in `block in top_level'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/application.rb:147:in `run_with_threads'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/application.rb:132:in `top_level'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/application.rb:83:in `block in run'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/application.rb:214:in `standard_exception_handling'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/application.rb:80:in `run'
bin/rake:13:in `<top (required)>'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/lib/bundler/cli/exec.rb:58:in `load'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/lib/bundler/cli/exec.rb:58:in `kernel_load'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/lib/bundler/cli/exec.rb:23:in `run'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/lib/bundler/cli.rb:451:in `exec'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/lib/bundler/vendor/thor/lib/thor/command.rb:28:in `run'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/lib/bundler/vendor/thor/lib/thor.rb:527:in `dispatch'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/lib/bundler/cli.rb:34:in `dispatch'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/lib/bundler/vendor/thor/lib/thor/base.rb:584:in `start'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/lib/bundler/cli.rb:28:in `start'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/exe/bundle:28:in `block in <top (required)>'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/lib/bundler/friendly_errors.rb:117:in `with_friendly_errors'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/exe/bundle:20:in `<top (required)>'
/usr/local/bin/bundle:25:in `load'
/usr/local/bin/bundle:25:in `<main>'
Tasks: TOP => uploads:migrate_to_s3
유사한 미해결 문제들:
앞서 언급하신 다른 토픽 중 업로드를 수동으로 완료하는 방법에 대한 설명이 있는 곳이 있을까요?
그것은 최종 실패 계층일 뿐, 실제 오류는 언급된 대로 더 위쪽에 있습니다:
아니요, 보지 못했습니다. 하지만 컴파일 후 자동으로 추가되지 않는 데에는 분명 이유가 있을 것이며, 이 오류를 확인해야 할 것입니다. 오류를 확인하는 방법이 명시되어 있는지 확인해 볼 수 있을 것 같습니다.
다시 시도해 보았습니다. app.yml에 필요한 S3 연결을 추가하고 다시 컴파일했습니다. 이번에는 after_assets_precompile을 제거했습니다. 모든 URL이 CDN으로 변경되었고 스타일 파일이 로드되지 않았습니다. 컨테이너에 수동으로 접속하여 rake s3:upload_assets를 실행해 보니 다음 오류가 발생합니다.
Attempting to apply ASSETS S3 CORS ruleset in bucket cloudflarebucketname.
rake aborted!
Aws::S3::Errors::AccessDenied: Access Denied (Aws::S3::Errors::AccessDenied)
다음과 같이 시도해 보면: rake uploads:migrate_to_s3 --trace
다음과 같은 오류가 발생합니다:
Migrating uploads to S3 for 'default'...
Some uploads were not migrated to the new scheme. Running the migration, this may take a while...
rake aborted!
FileStore::ToS3MigrationError: Some uploads could not be migrated to the new scheme. You need to fix this manually. (FileStore::ToS3MigrationError)
"rake s3:upload_assets"의 전체 오류 메시지:
root@domain-app:/var/www/discourse# rake s3:upload_assets --trace
Plugin name is 'DiscourseMatheditor', but plugin directory is named 'discourse-matheditor'
Plugin name is 'discourse-post-voting', but plugin directory is named 'discourse-question-answer'
Plugin name is 'discourse-topic-voting', but plugin directory is named 'discourse-voting'
** Invoke s3:upload_assets (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke s3:ensure_cors_rules (first_time)
** Invoke environment
** Execute s3:ensure_cors_rules
Installing CORS rules...
Attempting to apply ASSETS S3 CORS ruleset in bucket cloudflarebucketname.
rake aborted!
Aws::S3::Errors::AccessDenied: Access Denied (Aws::S3::Errors::AccessDenied)
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/aws-sdk-core-3.191.3/lib/seahorse/client/plugins/raise_response_errors.rb:17:in `call'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/aws-sdk-s3-1.143.0/lib/aws-sdk-s3/plugins/sse_cpk.rb:24:in `call'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/aws-sdk-s3-1.143.0/lib/aws-sdk-s3/plugins/dualstack.rb:21:in `call'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/aws-sdk-s3-1.143.0/lib/aws-sdk-s3/plugins/accelerate.rb:43:in `call'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/aws-sdk-core-3.191.3/lib/aws-sdk-core/plugins/checksum_algorithm.rb:111:in `call'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/aws-sdk-core-3.191.3/lib/aws-sdk-core/plugins/jsonvalue_converter.rb:16:in `call'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/aws-sdk-core-3.191.3/lib/aws-sdk-core/plugins/idempotency_token.rb:19:in `call'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/aws-sdk-core-3.191.3/lib/aws-sdk-core/plugins/param_converter.rb:26:in `call'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/aws-sdk-core-3.191.3/lib/seahorse/client/plugins/request_callback.rb:89:in `call'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/aws-sdk-core-3.191.3/lib/aws-sdk-core/plugins/response_paging.rb:12:in `call'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/aws-sdk-core-3.191.3/lib/seahorse/client/plugins/response_target.rb:24:in `call'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/aws-sdk-core-3.191.3/lib/seahorse/client/request.rb:72:in `send_request'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/aws-sdk-s3-1.143.0/lib/aws-sdk-s3/client.rb:5424:in `get_bucket_cors'
/var/www/discourse/lib/s3_helper.rb:385:in `fetch_bucket_cors_rules'
/var/www/discourse/lib/s3_helper.rb:166:in `ensure_cors!'
/var/www/discourse/lib/s3_cors_rulesets.rb:60:in `sync'
/var/www/discourse/lib/tasks/s3.rake:184:in `block in <main>'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/task.rb:281:in `block in execute'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/task.rb:281:in `each'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/task.rb:281:in `execute'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/task.rb:199:in `synchronize'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/task.rb:199:in `invoke_with_call_chain'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/task.rb:243:in `block in invoke_prerequisites'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/task.rb:241:in `each'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/task.rb:241:in `invoke_prerequisites'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/task.rb:218:in `block in invoke_with_call_chain'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/task.rb:199:in `synchronize'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/task.rb:199:in `invoke_with_call_chain'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/task.rb:188:in `invoke'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/application.rb:188:in `invoke_task'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/application.rb:138:in `block (2 levels) in top_level'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/application.rb:138:in `each'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/application.rb:138:in `block in top_level'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/application.rb:147:in `run_with_threads'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/application.rb:132:in `top_level'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/application.rb:83:in `block in run'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/application.rb:214:in `standard_exception_handling'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.2.1/lib/rake/application.rb:80:in `run'
bin/rake:13:in `<top (required)>'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/lib/bundler/cli/exec.rb:58:in `load'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/lib/bundler/cli/exec.rb:58:in `kernel_load'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/lib/bundler/cli/exec.rb:23:in `run'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/lib/bundler/cli.rb:451:in `exec'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/lib/bundler/vendor/thor/lib/thor/command.rb:28:in `run'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/lib/bundler/vendor/thor/lib/thor.rb:527:in `dispatch'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/lib/bundler/cli.rb:34:in `dispatch'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/lib/bundler/vendor/thor/lib/thor/base.rb:584:in `start'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/lib/bundler/cli.rb:28:in `start'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/exe/bundle:28:in `block in <top (required)>'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/lib/bundler/friendly_errors.rb:117:in `with_friendly_errors'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/exe/bundle:20:in `<top (required)>'
/usr/local/bin/bundle:25:in `load'
/usr/local/bin/bundle:25:in `<main>'
Tasks: TOP => s3:upload_assets => s3:ensure_cors_rules
이 상황에서 벗어나는 것이 어렵습니다.
어떤 직감이 S3 코드가 컴파일 후에만 실행되는 경우 아마존 S3만 지원한다고 말하고 있습니다. 어떻게 생각하시나요?
저한테는 잘 동작합니다. CORS 규칙을 건너뛰는 설정이 있는 것 같습니다. 해당 설정이 무엇인지 확인하려면 업로드를 위한 S3 호환 객체 저장소 제공자 구성을 참고해 보세요.
이것?: DISCOURSE_S3_INSTALL_CORS_RULE: false
이 방법은 잘 작동했지만, 문제가 하나 있습니다. theme-javascripts 파일이 S3에 업로드되지 않습니다. 당연히 사이트 디자인이 손상됩니다. assets 폴더만 로드됩니다. 다른 디자인 파일을 업로드하려면 어떻게 해야 할까요?
이것은 내가 당신에게 rake 태스크를 호출하여 s3에 업로드하는 부분을 포함하도록 말하는 마지막입니다.
행운을 빕니다.
무엇을 놓치고 있을까요? 아래 코드를 첨부했는데, 재빌드 시 에셋 파일은 로드되지만 테마 파일은 로드되지 않습니다.
컨테이너에 진입하여 rake uploads:migrate_to_s3를 실행하면 다음과 같은 오류가 발생합니다:
Updating the URLs in the database...
Removing old optimized images...
Flagging all posts containing lightboxes for rebake...
1001 posts were flagged for a rebake
rake aborted!
FileStore::ToS3MigrationError: 9 of 3769 uploads are not migrated to S3. S3 migration failed for db 'default'. (FileStore::ToS3MigrationError)
제 app.yml 파일은 다음과 같습니다. 테마 자바스크립트와 스타일시트가 업로드되지 않아 이 설정을 끄고 있습니다: DISCOURSE_CDN_URL.
자정에 다시 열어 컴파일해 보겠지만, 제가 뭘 놓쳤는지 모르겠습니다. "S3에 업로드하는 rake 태스크"라는 말의 다른 의미를 찾아보려 검색해 보았지만, 다른 내용은 찾지 못했습니다.
DISCOURSE_USE_S3: true
DISCOURSE_S3_REGION: 'auto'
DISCOURSE_S3_ENDPOINT: 'https://xxxxx.eu.r2.cloudflarestorage.com'
DISCOURSE_S3_ACCESS_KEY_ID: 'xxxxx'
DISCOURSE_S3_SECRET_ACCESS_KEY: 'xxxxx'
DISCOURSE_S3_CDN_URL: 'https://cdn.xxxxx.com'
#DISCOURSE_CDN_URL: 'https://cdn.xxxxx.com'
DISCOURSE_S3_BUCKET: 'cloudflarer2xxxxx'
#DISCOURSE_S3_BACKUP_BUCKET: 'cloudflarer2xxxxxbackups'
#DISCOURSE_BACKUP_LOCATION: 's3'
DISCOURSE_INCLUDE_S3_UPLOADS_IN_BACKUPS: true
DISCOURSE_S3_INSTALL_CORS_RULE: false
시간을 낭비하게 해서 죄송하지만, 사용자 문서에 이러한 문제가 포함되면 좋겠습니다. 이제 r2가 작동한다는 것을 알게 되었습니다. 다음 두 설정만 추가하면 됩니다:
DISCOURSE_S3_REGION: 'auto'
DISCOURSE_S3_INSTALL_CORS_RULE: false
사이트의 이미지와 에셋 폴더를 S3 영역으로 이동할 수 있습니다. 문제는 테마 파일과 스타일 파일이 전송되지 않는다는 것이며, 자정에 다시 시도해 보겠습니다. 성공할 수 있기를 바라며, 해결 방법을 설명한 후 이 문제를 해결된 것으로 표시할 것입니다.
참고: PostgreSQL 서버는 분리되어 있으며, localhost의 것을 사용하지 않습니다. 이로 인해 문제가 발생하지는 않을 것으로 생각합니다.
시간을 내어 주신 모든 분들께 감사드립니다.
이것이 자산을 업로드하기 위해 실행해야 하는 명령어입니다. 제 추측으로는 여전히 자산이 grin에 업로드되지 못하게 하는 무언가가 잘못되어 있을 것입니다.
좋습니다. 제가 잘못하고 있지 않다면 문제를 찾아야 합니다. 컨테이너에 들어와 rake s3:upload_assets 코드를 실행하면 모든 것이 정상적으로 보입니다. DISCOURSE_CDN_URL: 'https://cdn.xxxxx.com' 설정을 켜거나 끌어도 스타일 파일(테마 JavaScript 및 스타일시트)이 로드되지 않습니다.
rake s3:upload_assets --trace
Plugin name is 'DiscourseMatheditor', but plugin directory is named 'discourse-matheditor'
Plugin name is 'discourse-post-voting', but plugin directory is named 'discourse-question-answer'
Plugin name is 'discourse-topic-voting', but plugin directory is named 'discourse-voting'
** Invoke s3:upload_assets (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke s3:ensure_cors_rules (first_time)
** Invoke environment
** Execute s3:ensure_cors_rules
Installing CORS rules...
skipping
** Execute s3:upload_assets Skipping: assets/break_string-cc617154cd04790e.js
....
....
....
말씀드린 대로, 제가 잘못하고 있지 않다면 오류를 찾아 수정하는 방법을 알아내려 합니다. 개선 사항이 있으면 여기에 추가하겠습니다. 감사합니다.
안녕하세요 여러분,
Cloudflare R2를 Discourse 포럼에서 업로드와 백업 모두에 성공적으로 설정한 경험과 단계를 공유하고자 합니다. Cloudflare R2를 Discourse와 함께 사용하려는 분들에게 도움이 되기를 바랍니다.
설정 개요:
- 플랫폼: Discourse (Bitnami 설치)
- 버킷: Cloudflare R2
- 커스텀 도메인: 파일을 공개적으로 서빙하기 위해 설정
- 구성: Discourse 사이트 설정을 통해 전적으로 수행 (환경 변수는 변경하지 않음)
단계별 가이드:
- Cloudflare R2 버킷 생성:
- Cloudflare 계정에 로그인하고 R2 저장소로 이동하세요.
- Discourse 업로드용 새 버킷을 생성하세요 (예:
forum-uploads). - 버킷 S3 API URL, 액세스 키 ID, 비밀 액세스 키를 기록해 두세요.
- CDN용 커스텀 도메인 설정:
- R2 버킷 콘텐츠를 공개적으로 서빙하려면 Cloudflare에서 커스텀 도메인을 생성하세요.
- 예를 들어, 저는
forumfiles.example.in을 사용했습니다. - DNS 설정을 Cloudflare에서 제공한 CNAME으로 지시하도록 구성해야 합니다. 제 도메인이 Cloudflare에 있으므로 이 과정은 자동으로 처리되었습니다.
- Discourse 사이트 설정 구성:
- s3_bucket: R2 버킷 이름 (예:
forum-uploads). - s3_region: US East (N. Virginia)로 설정합니다. 자동 옵션이 없었습니다.
- s3_endpoint: Cloudflare에서 제공한 버킷 S3 API URL을 사용하세요 (예:
https://<your-bucket-unique-id>.r2.cloudflarestorage.com). - s3_access_key_id: R2 액세스 키 ID.
- s3_secret_access_key: R2 비밀 액세스 키.
- s3_cdn_url: CDN용 커스텀 도메인 (예:
https://forumfiles.example.in).
- s3_bucket: R2 버킷 이름 (예:
- enable s3 backups 및 enable s3 uploads가 체크되어 있는지 확인하세요.
- 권한 및 CORS 조정:
- R2 버킷을 비공개로 설정하고 CORS 정책을 구성하세요:
[
{
"AllowedHeaders": ["*"],
"AllowedMethods": ["GET", "POST", "PUT", "HEAD"],
"AllowedOrigins": ["*"],
"ExposeHeaders": ["ETag"],
"MaxAgeSeconds": 3000
}
]
- 이를 통해 CORS 문제 없이 업로드가 정상적으로 작동하도록 보장합니다.
- 설정 테스트:
- Discourse 포럼을 통해 테스트 파일이나 이미지를 업로드하여 업로드가 정상적으로 작동하는지 확인하세요.
- 파일이 커스텀 도메인(예:
https://forumfiles.example.in/original/1X/...)을 통해 접근 가능한지 확인하세요. - 백업을 확인하세요. 백업 실행에 성공했습니다. R2 버킷에서 교차 확인했으며 사이트 설정에도 목록으로 표시됩니다.
결론:
이 단계를 따름으로써 Cloudflare R2를 Discourse에 원활하게 통합하여 업로드와 백업을 효율적으로 처리할 수 있었습니다. 질문이 있거나 문제가 발생하면 자유롭게 질문해 주세요!
Discourse가 Cloudflare R2에서 파일을 다운로드할 수 있는지 테스트해 보셨나요? 예를 들어 인스턴스의 완전한 백업에 S3 업로드를 포함하는 경우입니다.
Cloudflare의 R2 S3 API에서 일부 기능이 누락된 것으로 보이며, migrate_to_s3도 작동하지 않는 것 같습니다.

