Amazon CloudFront
Developer Guide (API Version 2016-09-29)

Configuring Error Response Behavior

You can use either the CloudFront API or console to configure CloudFront error responses. For information about using the CloudFront API to configure error responses, go to PUT Distribution Config in the Amazon CloudFront API Reference, and see the CustomErrorResponses element.

To configure CloudFront error responses using the console

  1. Create the custom error pages that you want CloudFront to return to viewers when your origin returns HTTP 4xx or 5xx errors. Save the pages in a location that is accessible to CloudFront.

    We recommend that you store custom error pages in an Amazon S3 bucket even if you're using a custom origin. If you store custom error pages on an HTTP server and the server starts to return 5xx errors, CloudFront can't get the files that you want to return to viewers because the origin server is unavailable.

  2. Confirm that you have granted CloudFront at least read permission to your custom error page objects.

    For more information about Amazon S3 permissions, see Access Control in the Amazon Simple Storage Service Developer Guide. For information on using the Amazon S3 console to update permissions, go to the Amazon Simple Storage Service Console User Guide.

  3. (Optional) Configure your origin server to add Cache-Control directives or an Expires header along with the error response for specific objects, if applicable. For more information, see Controlling How Long CloudFront Caches Errors.

  4. Sign in to the AWS Management Console and open the CloudFront console at https://console.aws.amazon.com/cloudfront/.

  5. In the list of distributions, select the distribution to update and choose Distribution Settings.

  6. Choose the Error Pages tab. Then either choose Create Custom Error Response, or choose an existing error code and choose Edit.

    
									Select Web as the distribution type.
  7. Enter the applicable values. For more information, see Custom Error Pages and Error Caching.

  8. If you configured CloudFront to return custom error pages, add or update the applicable cache behaviors. For more information, see Creating or Updating a Cache Behavior for Custom Error Pages.

  9. To save your changes, choose Yes, Edit.