מחזיר 500 בעת בקשת אווטארים מותאמים אישית של משתמשים

סיכום מבוסס בינה מלאכותית

A user reported a 500 error when accessing custom avatars in Discourse, despite successful uploads to Cloudflare R2 (S3-compatible). The issue was traced to the server’s inability to access the S3 storage due to network restrictions, particularly in regions like China where connections to external services may be blocked. MoRanYue resolved the issue by setting HTTP_PROXY and HTTPS_PROXY environment variables to a proxy server that could access the S3 service. This solution was confirmed by avidseeker, who sought clarification on the fix. The discussion highlights potential issues with S3 compatibility and network access in unsupported installations, especially when using external storage services.

I tried to upload a custom avatar, it could be succesfully uploaded, but when requesting https://example.com/user_avatar/example.com/example_user/96/11_2.png, it just returned 500 error. The default anonymous avatar has no this error.

Latest master Discourse branch.
Cloudflare R2 is used as my S3 storage.

Are you on an unsupported-install?

In any case 500 alone isn’t sufficient information. Please share the related log info and someone might help you.

Of course. By the way, I have used Cloudflare R2 (S3-compatible) to store upload content, when I checked out files in the bucket, the avatar file was actually there, but clients could not access it with https://example.com/user_avatar/example.com/example_user/96/11_2.png, it’s so weird.

ב-production.log, מצאתי את השורה הזו:

Processing by UserAvatarsController#show as PNG
  Parameters: {"hostname" => "echonet.icu", "username" => "where", "size" => "288", "version" => "12_2"}
Completed 418  in 599ms (Views: 4.1ms | ActiveRecord: 0.0ms (0 queries, 0 cached) | GC: 0.4ms)

This may be related to:

Could be an S3 issue with the latest version :thinking:.

בסדר, הלוואי שזו רק בעיה ששייכת לגרסת הלילה הנוכחית. זה נפתר על ידי הגדרת פרוקסי.

Hey @MoRanYue, could you elaborate more on how you solved it?

I facing the same problem.

Thanks

@avidseeker
כאשר אתה משתמש בשירות OSS והשרת שלך לא יכול לגשת אליו, לדוגמה, אתה נמצא בסין והחיבורים של השרת שלך ל-Cloudflare R2 נחסמים על ידי ספק האינטרנט המקומי. כאשר לקוחות מנסים לרכוש משאבי אווטאר מותאמים אישית, השרת שלך צריך לרכוש אותו מה-OSS, אך נכשל, ואז מחזיר 500 ללקוחות.

במקרה שלי, הגדרת שני משתני סביבה: HTTP_PROXY ו-HTTPS_PROXY לשרת פרוקסי שיכול לגשת לשירות ה-OSS שלך. אם התקנת את Discourse באמצעות התקנה סטנדרטית, בקובץ app.xml שלך אמור להיות שדה הנקרא env, הוסף את שני המשתנים הללו ואז תוכל להריץ. השתמשתי בהתקנה לא נתמכת ומשתמש ב-Systemd לניהול Discourse, אז הוספתי שני פרמטרים של Environment בקובץ .service.

אני לא יודע אם במדינה שלך יש מערכת צנזורה ברשת. אם כן, אני יכול להניח שאתה כבר יודע מה לעשות; אם לא, בדוק את הסטטוס המקוון של שירות ה-OSS שלך ואת ההגדרות שלך לגבי S3.