S3 upload bucket, cdn url and bucket name in CNAME

I was recently looking at doing this, and wanted to chime in with a reason why it is useful.

We use a free Cloudflare plan (as we’re a small forum) and it works great. We turn off rocketloader etc and just use it like a decent pull CDN by pointing the Cloudflare subdomain DNS entry (forum.) at the discourse instance and all is good. It speeds things up and protects our server nicely.

When we wanted to switch to use S3 for uploads from local files, we realized that we can’t use Cloudflare for our free CDN for these often large images. This means our S3 bill is now getting larger (lots of GETs and repeated bandwidth) and it is pretty slow generally just used as a file store in the sky (for topics with lots of images in them). We can set up AWS Cloudfront in-front of S3 and set-up Discourse like that to improve the speed but that too costs more money, but what we really wanted to do is use the free Cloudflare to save us the bandwidth and surge requests.

Cloudflare and S3 require the virtual DNS naming that Discourse prohibits:

https://support.cloudflare.com/hc/en-us/articles/200168926-How-do-I-use-CloudFlare-with-Amazon-s-S3-Service-

Now @codinghorror is correct that if we were hosting our own wildcard SSL cert then this might be an issue with a files.myforum.com.s3.amazonaws.com due to the periods in the name, but we’re not. We’re using Cloudflares free SSL support. Between Cloudflare and our secure it isn’t end-to-end secure, but we’re ok with that as it’s a free feature.

So for our case, where we don’t have a local wildcard cert and don’t need that, it would be really beneficial to our running costs to be able to use AWS virtual hosting of buckets using these period names.

1 Like