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.
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.
@avidseeker
Wanneer u een OSS-service gebruikt en uw server er geen toegang toe heeft, bijvoorbeeld, u bent in China en de verbindingen van uw server met Cloudflare R2 worden geblokkeerd door de lokale ISP. Wanneer clients proberen aangepaste avatarbronnen te verkrijgen, moet uw server deze verkrijgen van de OSS, maar faalt, en retourneert vervolgens 500 aan de clients.
In mijn geval, het instellen van twee omgevingsvariabelen: HTTP_PROXY en HTTPS_PROXY naar een proxyserver die toegang heeft tot uw OSS-service. Als u Discourse met standaardinstallatie hebt geïnstalleerd, moet in uw app.xml een veld genaamd env staan, voeg die twee variabelen toe en dan kunt u uitvoeren. Ik heb een niet-ondersteunde installatie gebruikt en Systemd gebruikt om Discourse te beheren, dus ik heb twee Environment-parameters toegevoegd in het .service-bestand.
Ik weet niet of uw land een netwerk censuursysteem heeft. Zo ja, dan kan ik aannemen dat u al weet wat u moet doen; zo niet, controleer de online status van uw OSS-service en uw instellingen met betrekking tot S3.