# S3 upload bucket, cdn url and bucket name in CNAME

**URL:** https://meta.discourse.org/t/s3-upload-bucket-cdn-url-and-bucket-name-in-cname/42549
**Category:** Support
**Created:** [4월 14, 2016, 9:40오전 UTC](https://meta.discourse.org/t/s3-upload-bucket-cdn-url-and-bucket-name-in-cname/42549 "2016-04-14T09:40:35Z")
**Posts on this page:** 1
**Showing post:** 7

<div class="post-metadata">

### Author: ![fearlessfrog](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fearlessfrog/32/119653_2.png) [@fearlessfrog](https://meta.discourse.org/u/fearlessfrog)
#### Post date: [6월 22, 2016, 8:46오후 UTC](https://meta.discourse.org/t/s3-upload-bucket-cdn-url-and-bucket-name-in-cname/42549/7 "2016-06-22T20:46:17Z")

</div>

As a follow-up to this, and I’m not sure if this is madness or not 🙂 but one way around that seems to work is to do the following:

- Set up S3 uploads i.e. mybucket and then let Discourse use that.

- In AWS create a CloudFront distribution for that S3 bucket. Set up an alternative CNAME called ‘[uploads.myforum.com](http://uploads.myforum.com)’.

- In CloudFlare set up a CNAME and active cache for [uploads.myforum.com](http://uploads.myforum.com) and point it at the [xyz.cloudfront.net](http://xyz.cloudfront.net) AWS domain name for that distribution.

- Tell Discourse to use the CDN URL [https://uploads.myforum.com](https://uploads.myforum.com) (and I guess rebake posts, although the old Cloudfront URL should resolve still fine?)

That way you get a wildcard HTTPS on your images and (I guess?) lower CloudFront and S3 GETs and bandwidth. A couple of CURL tests show Cloudflare is caching ok in-front of Cloudfront.

So, basically using CloudFront’s ability to have an alternative CNAME to get around the periods in S3 upload buckets in Discourse.

This all seems to work ok (I think?), but the the Discourse CDN setting doesn’t seem to do what I thought it would do, i.e:

> [@Want to understand s3\_cdn\_url files setting](https://meta.discourse.org/t/want-to-understand-s3-cdn-url-files-setting/45799):
>
> So we’re experimenting on using S3 for uploads. S3 is quite slow for, well anything really, so wanted to put a CDN like Cloudfront in-front of it. The setting :s3\_cdn\_url seems to be ideal for that. Using it is not quite what I expected though, so wanted help to check my understanding. I can understand that it doesn’t change older posts without rebaking, but since enabling we see this on new posts: So, the actual optimized/thumb is shown in straight Slow S3, but the full inside the l…

If all the URLs in the uploads used the CDN value then we’d be good.

---

_[View the full topic](https://meta.discourse.org/t/s3-upload-bucket-cdn-url-and-bucket-name-in-cname/42549)._
