如何在S3中存储Cloudfront自定义错误页面?

我在AWS负载平衡器上插入了Cloudfront。

我在AWS文档中看到,我可以自定义Cloudfront自定义错误页面。 我尝试在S3中存储这些错误页面,因为它是在AWS文档中推荐的,但它不起作用。 该文件说:

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. 

我的错误页面在S3中,path为“my-app-bucket / errorpage.html”。

我尝试在Cloudfrontconfiguration中链接此文件,但是出现以下错误:

Cloudfront自定义错误页面配置

如果我尝试值/my-app-bucket/errorpage.html,则Cloudfront会将请求redirect到ELB原点,并获得404。

谁能解释我如何做这个configuration?

这些提示来自http://blog.celingest.com/en/2013/12/12/cloudfront-configuring-custom-error-pages/

  • 您需要添加另一个CloudFront原点,指向错误页面所在的存储桶
  • 新创build的源的caching行为应该具有指向错误页面所在的文件夹(在错误页面存储桶中)的path模式
  • 然后,您可以在创build自定义错误响应configuration时在“响应页面path”中使用该path