Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change http response code on an object in Amazon S3

I have a webpage hosted on Amazon S3 but I don't want the http response code to be 200. The page is a maintenance page that I'll redirect traffic to when I take our main website down for maintenance.

I want the Amazon S3 page to include a response header of:

HTTP/1.1 503 Service unavailable

Amazon give the ability to add some metadata to the S3 Object but there is nothing for the http status code.

Is it possible?

like image 780
Tom Avatar asked Jun 12 '14 10:06

Tom


People also ask

How do I change the code on my S3 bucket?

To directly edit a file on S3, use edit subcommand. Then, open a file with the default editor specified by $EDITOR .

Can you update an object in S3?

First, sign in to the AWS Management Console and navigate to Amazon S3. In the Buckets menu, select the bucket with the object ACLs you would like to modify. In the Objects tab, select an object to update. Select the Permissions tab to view the current ACL for the object.

Which HTTP code indicates a successful upload of an object to Amazon S3?

HTTP 200 code indicates a successful write to S3.

Does AWS S3 support HTTP?

Amazon S3 website endpoints do not support HTTPS or access points. If you want to use HTTPS, you can use Amazon CloudFront to serve a static website hosted on Amazon S3.


2 Answers

Not sure which browsers, or crawlers, that supports this. But you could potentially use the meta http-equiv status meta tag to accomplish this.

<meta http-equiv="status" content="503 Service Unavailable" />

The specification says to treat it in the same way as if 503 had been sent as the status code.

like image 115
Linus Unnebäck Avatar answered Sep 18 '22 20:09

Linus Unnebäck


You cannot customize the status code for S3 responses.

You can use API Gateway as a proxy to your S3 website error page where you can customize status codes returned.

like image 44
Steve Buzonas Avatar answered Sep 18 '22 20:09

Steve Buzonas