A Static Headache: Custom Headers in Cloudfront are Unpleasant

A Static Headache: Custom Headers in Cloudfront are Unpleasant

https://lastweekinaws.com/blog/a-static-headache.html


Related discussions:

Hmm? What headers is he talking about? Just tried out a couple of cloudfront enabled sites I’ve set up. A+ for all of them, and absolutely no headers injected, and no Lambda@Edge used.

The HSTS stuff and a few others— check out the linked function for the complete list.

I recently did the same HSTS setup for two sites using CloudFlare and CloudFront. Where CloudFlare was user friendly and easy and took a few clicks, CloudFront required that I write a Lambda function to intercept every request. CloudFront is definitely lacking basic features that other CDNs have.

CloudFront is a CDN first and foremost, Cloudflare is a proxy with the addition of a CDN network, cloudflare is made to rewrite content headers and such.

All CDNs are proxies unless you push the data to them. CloudFront is a proxy.

CloudFront isn’t the problem, it’s S3 that won’t permit you to set those headers in object metadata.

If you have a proxy between CloudFront and S3, you can inject headers there, and while you’re at it you can implement high availability of your origin by using buckets in more than one region as the upstream servers.

So sure, having to use infrastructure to set headers sucks, but a proxy on ec2 with a S3 vpc end point has its advantages.

S3 can do it, CloudFront can do it, a sleep deprived TAM can do it, I don’t care— I just don’t want to have to build a custom function to do something this basic that Amazon doesn’t offer out of the box.

Your proxy idea has merit, but you’re also multiplying the cost for small deployments substantially.

Thanks for this. It’s always seemed odd to me how easy it is to set up CloudFront in front of an S3 bucket-based website, yet also returning common and widely-used HTTP headers isn’t easy at all. To me it seems like what should be an “out of the box” feature.

What’s your reason for needing HSTS?

The slightly arbitrary ssl labs rating.

I can’t think of a compelling reason why you would need to enforce secure transport with the HSTS header for a statically hosted blog.

Perhaps, they are concerned someone will edit the world class content on the fly and tarnish the good name of the site.

Or perhaps someone’s just looking for something to complain about publicly.

Most people would just include a meta refresh to the https site and be happy with it.