Cloudflare R2: ניווט בהגדרות וטיפול בבעיות תצורה

I can download backups, I’ve never had any problems with this.

With S3 uploads included?

Thanks very use full, just when I upload in copy the image from clipboard is not working, do you face this problem?, in the end was uploaded to R2 but not visible in post:

Did you look at the image URL, what does it look like?

So we still can’t configure r2 through app. yml?Only through website setting,that is DB_S3_CONFIG?

Use this method,can you upload the old local uploads to R2, via rake uploads : migrate to s3

Hey, thank you all for this.

If I understand this correctly, “DISCOURSE_CDN_URL” can be the same as “DISCOURSE_S3_CDN_URL”, which is the custom public domain linked to the bucket on Cloudflare? Or is some other configuration needed for this?

Yes, you must add the same domain name to the discourse container.yml. Here is an example of usage:

  ## The HTTP or HTTPS CDN address for this Discourse instance (configured to pull)
  ## See https://meta.discourse.org/t/14857 for details
  #DISCOURSE_CDN_URL: https://discourse-cdn.example.com
  #DISCOURSE_USE_S3: true
  DISCOURSE_S3_REGION: 'auto'
  DISCOURSE_S3_ENDPOINT: 'https://45dv544v56x****************************564564.eu.r2.cloudflarestorage.com'
  DISCOURSE_S3_ACCESS_KEY_ID: '564dfds4f54sdfs********65564545'
  DISCOURSE_S3_SECRET_ACCESS_KEY: 'sddfsdf564564**********6545sd4f54sd56f4s6d5'
  DISCOURSE_S3_CDN_URL: 'https://cdn.discourse.com.br'
  ##DISCOURSE_CDN_URL: 'https://cdn.discourse.com.br'
  #DISCOURSE_S3_BUCKET: 'cloudflarebucketname'
  #DISCOURSE_S3_BACKUP_BUCKET: 'cloudflarebackupbucketname/backups'
  #DISCOURSE_BACKUP_LOCATION: 's3'
  DISCOURSE_INCLUDE_S3_UPLOADS_IN_BACKUPS: true
  DISCOURSE_S3_INSTALL_CORS_RULE: false

The settings disabled with this character should be configured via the admin panel; examples are provided in the code. If you prefer, you can also enable these settings within the configuration section, it is up to you.

לייק 1

This option will break the site when set on app.yml, as not all static files like JavaScript are hosted on R2 for some reason.

לייק 1

זה נהדר. עקבתי אחר המדריך בפוסט #39 וכל העבודה. יש לי רק הצעה אחת ו-2 שאלות.

הצעה:
ממה שקראתי, כדאי להפוך את קבצי ה-CDN לזמינים לציבור ואת דלי הגיבוי לפרטי. אז יצרתי 2 דליים והשארתי את דלי הגיבוי פרטי תוך הפיכת דלי הקבצים לציבורי עם דומיין מותאם אישית. זה פשוט אומר שהייתי צריך להכניס 2 נתיבים שונים בשתי התיבות תחת אדמין.
ראיתי הרבה אנשים שמכניסים את הגיבויים שלהם כנתיב של דלי ברמה העליונה שלהם, האם אני חושב לא נכון לגבי זה? או שזו רק מוזרות עם CF R2?

ש1:
הוספתי את ‘DISCOURSE_INCLUDE_S3_UPLOADS_IN_BACKUPS: true’ בקובץ app.yml שלי ובניתי מחדש, אבל כשאני הולך לגיבויים ולוחץ על כפתור הגיבוי, אני עדיין מקבל את ההודעה שהעלאות לא יכללו. האם זה רק בגלל שלחלון הקופץ אין לוגיקה מתחתיו או שמשהו לא בסדר?

ש2:
אם אני רוצה להעביר את ההעלאות הנוכחיות ל-R2, מהן הפקודות התמציתיות?
חיפשתי וניסיתי:

./launcher enter app
rake uploads:migrate_to_s3
rake posts:rebake_uncooked_posts

אבל נראה שהפקודה הראשונה של rake עובדת רק אם אני מגדיר את אפשרויות ה-S3 בקובץ app.yml. האם זה נכון?

אם אעשה זאת, האם R2 ימשיך לעבוד?

לייק 1

בסדר, נבדק ונמצא חסר.
נראה שהפקודה הראשונה של rake עובדת רק עבור AWS.

rake aborted!
Seahorse::Client::NetworkingError: Failed to open TCP connection to exotics-unlimited.s3.auto.amazonaws.com:443 (getaddrinfo: Name or service not known) (Seahorse::Client::NetworkingError)

האם יש פקודה אחרת שעושה את אותו הדבר עם ספקי S3 אחרים?

לייק 1

Have you done any follow up to see if we can get R2 as a fully working solution?

R2 works fine; just don’t use or set this option: DISCOURSE_CDN_URL

Right, which means it’s not fully working because some static files are not being pushed/hosted correctly.
I’m just looking to make everything work instead of just some of it working.

לייק 1

אני לא מצליח למנוע מ-DC לחשוב שהוא AWS, למרות שזה CF R2, הגיבויים פשוט לא עולים. אני רוצה להשתמש בו רק עבור קבצי zip לגיבוי, במקום AWS. אני מאמין שמילאתי נכון את כל ההגדרות ושהטוקן גישה שלי הוא בעל היקף “קריאה וכתיבה של אובייקטים” עבור הדלי הספציפי הזה. הוספתי גם את מדיניות ה-CORS מהשרשור.

[2025-09-06 13:56:44] Gzipping archive, this may take a while...
[2025-09-06 13:56:49] Uploading archive...
[2025-09-06 13:56:49] EXCEPTION: Aws::S3::Errors::Forbidden
[2025-09-06 13:56:49] /var/www/discourse/vendor/bundle/ruby/3.3.0/gems/aws-sdk-s3-1.182.0/lib/aws-sdk-s3/object.rb:559:in `rescue in exists?'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/aws-sdk-s3-1.182.0/lib/aws-sdk-s3/object.rb:554:in `exists?'
/var/www/discourse/lib/backup_restore/s3_backup_store.rb:46:in `upload_file'
/var/www/discourse/lib/backup_restore/backuper.rb:351:in `upload_archive'
/var/www/discourse/lib/backup_restore/backuper.rb:41:in `run'
/var/www/discourse/script/spawn_backup_restore.rb:9:in `backup'
/var/www/discourse/script/spawn_backup_restore.rb:31:in `block in <main>'
/var/www/discourse/script/spawn_backup_restore.rb:4:in `fork'
/var/www/discourse/script/spawn_backup_restore.rb:4:in `<main>'
[2025-09-06 13:56:49] Deleting old backups...
[2025-09-06 13:56:49] Cleaning stuff up...
[2025-09-06 13:56:49] Removing archive from local storage...
[2025-09-06 13:56:49] Removing '.tar' leftovers...
[2025-09-06 13:56:49] Marking backup as finished...
[2025-09-06 13:56:49] Notifying 'Firsh' of the end of the backup...
[2025-09-06 13:56:54] Finished!

This seems to be working fine for me too! (remember to set the cdn url, otherwise uploads will work but gets won’t)