S3 CDN URL ignored when uploading into posts

AI-generated summary

A long-standing issue in Discourse is the S3 CDN URL being ignored when uploading into posts. This results in a generic bucket URL being used instead of the custom CDN URL set in s3 cdn url. This problem is particularly significant for users with private ACLs on their S3 buckets, as it causes broken images in the post preview window.

@DanielMarquard first reported the issue, and @timkelty expressed disappointment that it had gone unfixed for so long. @Stephen suggested that the implementation was not fully supported, but @timkelty argued that the behavior was broken and forced users to adopt an S3 configuration that AWS recommends against.

@sam proposed a potential fix, which was implemented by @vinothkannans. However, the issue regressed, as reported by @RGJ. @vinothkannans provided another fix, but it did not cover custom emojis in the preview, as noted by @Falco. Additionally, the fix did not apply to attachments, as pointed out by @applebee1558. A pull request to fix the attachment issue was submitted by @nbianca.

All of our traffic goes through CloudFront, and static content is fetched by CloudFront from one of several S3 buckets.

With uploads being sent to S3, Discourse embeds the content with a generic bucket URL despite our having s3 cdn url set. Once submitted, posts appear to use the correct URL set in s3 cdn url, although this may also be because we have DISCOURSE_CDN_URL set as well (both are set to the same URL).

The post preview window references the standard S3 URL seen in the unbaked post, though. This is a problem because we use a private ACL on files uploaded to our Discourse uploads bucket, as content on this bucket should never be accessed outside of CloudFront. The result is a broken image in the preview window.

2개의 좋아요

수년간 보고되어 왔는데도 아직까지 수정되지 않은 점이 실망스럽습니다.

@DanielMarquard 우회 방법을 찾았나요, 아니면 s3 ACL을 공개적으로 설정해야 했나요?

더 복잡한 구현이 완전히 지원되지 않는다는 점을 고려할 때, 이것이 깨졌다고 주장하는 것이 공평하지 않을 수 있습니다.

문서에 명시된 대로 S3 업로드는 정상적으로 작동하며 올바르게 동작합니다.

@Stephen 물론 해석의 여지가 있습니다…

저에게는 한 곳에서 CDN URL을 사용하고 다른 곳에서는 사용하지 않는 것이 “깨진” 상태처럼 보입니다. 또한 AWS가 실제로 권장하지 않는 S3 설정(공개 ACL을 S3 버킷에 적용)을 강제하고 있습니다.

Discourse 프로젝트에 대해서는 처음이지만, PR을 작성하는 데는 분명히 기여할 수 있습니다.

지금 수정하는 것이 좋을 수 있습니다. AWS가 공개 읽기 ACL에 대해 사용자에게 알리는 데 점점 더 신경을 쓰고 있기 때문입니다.

4개의 좋아요

현재 구현에는 IMG 태그가 더 이상 없으므로, 예를 들어:

![image|690x298,50%](upload://eGAOR4Xy4aRM2lwPIuTokBf60jS.png)

위 이미지에 CDN을 적용하는 것은 비교적 간단하며, 이를 통해 트래픽을 절약할 수 있습니다.

@vinothkannans 님, 미리보기가 CDN URL을 사용하도록 수정해 주시겠습니까?

현재 미리보기에는 다음이 표시됩니다:

<img src="//cdck-file-uploads-global.s3.dualstack.us-west-2.amazonaws.com/meta/original/3X/6/6/66ef078b3ef9da9aa1b3356cb21fe22a0d25eaf0.png" alt="image" class="resizable" width="345" height="149">

다음과 같은 CDN URL을 표시해야 합니다:

<img src="https://global.discourse-cdn.com/meta/original/3X/6/6/66ef078b3ef9da9aa1b3356cb21fe22a0d25eaf0.png" alt="image" class="resizable" width="345" height="149">
6개의 좋아요

아래 커밋에 따라 이제 수정되었습니다

6개의 좋아요

이 주제는 32시간 후 자동으로 닫혔습니다. 더 이상 새 답글을 작성할 수 없습니다.

S3 CDN URL ignored when uploading into posts에서 이어서 논의합니다:

이 문제가 다시 발생한 것 같습니다. 메타에서 재현할 수 있습니다.

3개의 좋아요

이건 @vinothkannans 또는 @falco 님이 확인해 주실 수 있을까요?

3개의 좋아요

최근 변경 사항에 따라, 이제 업로드된 파일의 URL을 초기 업로드 요청 자체에서 가져옵니다. 이전에는 /uploads/lookup-urls.json 엔드포인트에서 받아왔습니다. 이 커밋은 해당 문제를 수정해야 합니다.

5개의 좋아요

예를 들어 :allthethings: 이모티콘처럼, 이 수정이 미리보기에서 커스텀 이모티콘을 지원하지 않는 것 같습니다.

4개의 좋아요

데이터 내보내기나 기타 파일 첨부파일도 누락되어 있습니다. 이 파일들은 여전히 S3에서 제공됩니다.

그걸 고칠 수 있어요!

3개의 좋아요