S3 buckets containing periods not allowed

AI-generated summary

The discussion revolves around the restriction in Discourse of using periods in S3 bucket names. uppfinnarn initially points out the limitation, citing Amazon’s documentation, which allows periods in bucket names for CNAME-based access.

codinghorror explains that the restriction is due to issues with HTTPS and certificates when using periods in bucket names. However, uppfinnarn and delta argue that using SNI-based SSL certificates, such as those offered by Cloudflare, can mitigate these issues.

gingerman shares their experience of using Cloudflare to access S3 content and requests that the restriction be relaxed. delta and winterdj also express their desire to use S3 bucket names with periods, citing valid use cases.

However, codinghorror ultimately decides that the restriction will not be lifted, citing the potential for HTTPS issues. delta and theblazehen consider alternative solutions, including modifying the database or using a different CDN.

The discussion highlights the trade-offs between restricting S3 bucket names with periods and allowing users to configure their own solutions. Some users suggest that displaying a warning or documentation link could educate users about the potential issues while still allowing them to use bucket names with periods.

So, with the introduction of the s3_cdn_url setting, you can set a custom URL to be used instead of the long S3 URL.

Unfortunately, s3_upload_bucket doesn’t allow periods in the name… which means that if I, as per Amazon’s documentation, create a bucket called static.example.com and point a CNAME to it, I can set Discourse to print out URLs to static.example.com, but I can’t set it to actually upload to that bucket.

(I want to put Cloudflare in front of a CNAME, making for a low-cost but effective CDN. It’s not just for looks.)

2개의 좋아요

If periods are indeed supported we should relax the restriction … @techAPJ can you have a quick look

As I understood it, periods in the bucket name cause havoc with https and certificates so it is strongly discouraged that you do this. Unless you never plan to use https.

We ran into many problems with this, which is why it is disallowed. It is not random. It’s a resolution to a problem many Discourse instances faced.

5개의 좋아요

aha … well then let’s just leave it as is for now.

1개의 좋아요

This is a good point. However, I think it should be downgraded to a warning, rather than being outright forbidden.

While locking yourself out of HTTPS is a terrible idea on its own, both Amazon CloudFront and CloudFlare (off the top of my head) offer SNI-based SSL certificates that can be put in front of a bucket, even if the default certificate would no longer cover it.

CloudFront can be configured to pull from an S3 bucket of your choice (even if it’s named something different), but also costs money. Well invested money, one may argue, but money nonetheless. If one does not need the additional functionality of a full-fledged CDN, CloudFront is a slightly overkill solution to the problem of “I want my forum to load faster”.
(An incredibly convoluted pricing model doesn’t help… I think there’s an XKCD for this, but I can’t find it.)

CloudFlare is not as configurable, but also offer quite a few other features as well - as well as the very approachable price tag of free. With a properly named bucket and a DNS rule (possibly supplemented by some caching rules), you get an instant improvement to loading performance, with no downsides whatsoever.
Perhaps not as big of a difference as a full CDN would make, but hey, it’s free performance.

3개의 좋아요

@codinghorror @sam I am using a cloudflare CDN to access the S3 content (where discourse uploads all the files) and not directly.

s3 mandates to use bucket name like files.discourse.org to access its content through cname files

Is there a way to allow periods in the S3 name (may be with a warning for https issue for direct s3 use). This is a showstopper in my case to use S3 with cloudflare and discourse.

Thanks

2개의 좋아요

We worked around that here @gingerman :

5개의 좋아요

@fearlessfrog Thanks…I ended up doing exactly the same. I don’t know how I missed your thread earlier. Just to highlight - this approach has a limitation in terms of cache invalidation. we have to do separately invalidations in cloudfront and cloudflare (after rebaking posts). It would be great to automate them with a script at the very least.

I hit up on the same blocks eventually in terms of optimised image urls and was planning to start a thread today…Nice to know that you have already helped the team towards a fix in the below given thread. Kudos for that.

2개의 좋아요

Discourse에서 S3 버킷 이름에 마침표(.)를 허용하도록 +1을 표합니다. AWS 자체도 CNAME 기반의 S3 콘텐츠 접근에 대해 이를 허용하고 있습니다(실제로 권장하고도 있습니다). 제가 아는 바로는 Discourse의 s3_cdn_url 설정이 활용된다면 이전에 HTTPS와 관련하여 겪었던 문제들은 더 이상 문제가 되지 않을 것입니다. 특히 Cloudflare와 같은 서비스가 사용될 경우 그렇습니다(@uppfinnarn이 언급했듯이 SNI 기반 SSL 인증서는 이 문제를 해결합니다).

다가오는 릴리스에서 이 사항을 다시 검토해 주실 수 있을까요?

훌륭한 제품을 만들어 주셔서 감사합니다!

우리가 이미 S3_CDN_URL이 무엇이든 지원하고 있으므로, 이를 허용하면 어떤 이점이 있나요?

라파엘, 안녕하세요. 제가 뭔가 놓치고 있는 게 아니라면, 해당 파라미터가 Discourse가 CDN URL에서 가져오도록 허용하지만, 마침표가 포함된 S3 버킷 이름을 지정할 수 없다면 실제로 해당 버킷에 업로드를 할 수 없는 건가요? 그러면 CloudFront와 같은 추가적인 유료 제3자 서비스에서 대체 CNAME을 설정하는 것과 같은 어색한 우회 방법을 사용해야 하는데, 우리는 현재 CloudFront를 전혀 사용하지 않고 있고, 앞으로도 사용하지 않기를 원합니다.

(그리고 결국 왜 유효한 S3 버킷 이름인 것을 일괄적으로 거부하고 싶었는지는 도무지 이해가 안 됩니다!)

그러니까 https를 전혀 사용하지 않는다는 거죠? 위에서 언급한 것이 바로 그 주된 이유입니다.

1개의 좋아요

여기서 트레이드오프가 무엇인지 이해가 되지 않습니다.

점(.)이 포함된 버킷을 허용한다면, 연결 시 SSL 인증을 비활성화할 수 있는 설정을 추가해야 합니다. 그렇지 않으면 해당 기능을 사용하는 사람들이 Discourse와 S3 엔드포인트 사이에 SSL을 추가하는 프록시를 구성해야 하는데, 이 경우에도 프록시와 S3 엔드포인트 간 통신은 여전히 평문 HTTP로 이루어집니다.

그렇게까지 했는데, 그 이점은 무엇인가요?

1개의 좋아요

그래서 https를 전혀 사용하지 않는다는 뜻인가요? 위에서 언급한 대로 이것이 주된 이유입니다.

Jeff님, 저희는 Cloudflare를 통해 HTTPS를 사용하고 있습니다.

만약 점을 포함하는 버킷을 허용한다면, 연결 시 SSL 검증을 비활성화할 수 있는 설정을 추가해야 합니다. 그렇지 않으면 해당 기능을 사용하는 사람들이 Discourse와 S3 엔드포인트 사이에 SSL을 추가하는 프록시를 설정해야 하지만, 이 경우에도 프록시와 S3 엔드포인트 사이의 통신은 여전히 평문 HTTP로 이루어집니다.

Cloudflare가 이를 자동으로 감지하고 처리할 것으로 확신합니다. 추가 설정이 필요하지 않으며, 이전에도 다른 서비스에서 동일한 방식을 사용했던 경험이 있습니다.

문제가 있다고 판단되는 관례의 사용을 사용자에게 경고하고 싶은 마음은 충분히 이해합니다. 하지만 유효한 S3 버킷 이름에 마침표가 포함될 수 있으며(AWS 문서에서도 다양한 시나리오에서 이를 사용할 것을 권장하고 있습니다), 향후 이를 활성화하는 방안을 고려해 주실 수 있을까요?

아니요, 우리는 그것을 고려하지 않을 것입니다.

네, 감사합니다. 패치를 하거나 다른 대안을 찾아보겠습니다 :slight_smile:

대안은 무엇인가요? 그냥 도트가 없는 새로운 S3 버킷을 하나 만들어 보세요. 기존 버킷을 Discourse 업로드에 사용할 이유는 제가 생각하기엔 없습니다. 버킷 안에 Discourse와 무관한 랜덤한 객체가 섞여 있지 않아서 회계 처리도 더 쉬워집니다.

아마 이것보다는 덜 비효율적인 무언가가 되길 바랍니다(하지만 최소한 작동은 할 테니까).

CloudFront CDN은 선택 사항입니다. 점(.)이 없는 버킷 이름을 사용하여 원하는 다른 CDN을 사용할 수도 있으며, 그렇게 하면 HTTPS 문제도 발생하지 않습니다.

또한, 그 대화 내용을 읽으면서 떠오르는 것은 이 이미지뿐입니다.

(경고: 현재 미국 보안 자격증을 보유한 사람은 이 이미지를 여기에 공개해서는 안 됩니다.)

2개의 좋아요