1 Antwort
- Neueste
- Die meisten Stimmen
- Die meisten Kommentare
0
Hi, on your 2 questions:
- Error page: it is all described here how to configure it: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/GeneratingCustomErrorResponses.html#custom-error-pages-procedure
In particular, about the 404
If you configure CloudFront to return a custom error page for an HTTP status
code but the custom error page isn’t available, CloudFront returns to the viewer
the status code that CloudFront received from the origin that contains the custom
error pages. For example, suppose your custom origin returns a 500 status code
and you have configured CloudFront to get a custom error page for a 500 status
code from an Amazon S3 bucket. However, someone accidentally deleted the custom
error page from your bucket. CloudFront returns an HTTP 404 status code (Not Found)
to the viewer that requested the object.
- Re. close.html and index.html, you have to use Lambda@Edge: see https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-at-the-edge.html
For your purposes, you have 2 options: use Lambda@Edge whenCloudFront receives a response from the origin (origin response) or before CloudFront returns the response to the viewer (viewer response)
Look at this page for changing return code: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/GeneratingCustomErrorResponses.html#custom-error-pages-response-code
Look at this page for plenty of example along the line your index.html use case: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-examples.html#lambda-examples-access-request-body-examples
Hope it helps, Didier
Relevanter Inhalt
- AWS OFFICIALAktualisiert vor 3 Jahren
- AWS OFFICIALAktualisiert vor 2 Jahren
- AWS OFFICIALAktualisiert vor einem Jahr
Hi Didier, thank you for the advice.
I didn't think of using "origin response" or "viewer response" to change return code and contents in case of 404/403. So I will try writing lambda@edge code. "Edge function" is useful when to implement very simple requirement, but seems unsuitable for complex logic.