Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom headers on Amazon S3

Is it possible to have custom headers on Amazon S3 with arbitrary naming?

For example, I am using a CDN pointing to Amazon S3 as the origin server, and in order to enable advanced functionality on the CDN I need to use a custom header x-something-something...

I see it's possible to do this with x-amz-meta-(something) but what about something more general like x-(something)-(something) without the amz?

Amazon S3 custom headers

like image 736
Jeff Avatar asked Jan 18 '12 20:01

Jeff


People also ask

What is origin custom headers?

These custom headers enable you to send and gather information from your origin that you don't get with typical viewer requests. These headers can even be customized for each origin. CloudFront supports custom headers for both for custom and Amazon S3 origins. Topics.

Can AWS ALB add custom header?

As far as I know there is no way to set custom headers at the ALB level. You can however add CloudFront as a CDN in front of it, that allows you to set custom headers, which will then be passed on to the ALB.

How do I add a response header?

Select the web site where you want to add the custom HTTP response header. In the web site pane, double-click HTTP Response Headers in the IIS section. In the actions pane, select Add. In the Name box, type the custom HTTP header name.


2 Answers

This beautiful article explains it all https://medium.com/@tom.cook/edge-lambda-cloudfront-custom-headers-3d134a2c18a2

tldr:

You can't-do only with S3. You need to use CloudFront and Lambda via Lambda@Edge. It's an integration between Lambda and CloudFront. It allows you to run Lambdas within the CloudFront. This allows you to change headers among other things. So if you are ok accessing your S3 via CloudFront then this could be a viable option.

like image 169
aWebDeveloper Avatar answered Oct 15 '22 04:10

aWebDeveloper


I don't think it is possible with their current API. They cover the major headers you will need for caching and browser interoperability.

I think they are being safe in only allowing x-amz-meta- prefixed custom headers, possibly to keep from clashing with user selected headers when they update their api in the future.

If you need custom attributes attached to your objects, it should be trivial to parse out the x-amz-meta- in your client application.

like image 22
Kekoa Avatar answered Oct 15 '22 06:10

Kekoa