By using AWS re:Post, you agree to the Terms of Use

Questions tagged with Amazon CloudFront

Sort by most recent

Browse through the questions and answers listed below or filter and sort to narrow down your results.

Cloudfront Edge functions

I'm trying to play Instagram Video assets. The challenge is the videos are expirable. They expire every N mins. I'm brainstorming a solution where I set up my CDN (Cloudfront) which forwards the incoming requests to the original server (Instagram in this case), caches the video at CDN, and then keeps serving it without the need to request Instagram again. I don't want to download the videos and keep them in my bucket. I'd a look at CloudFront functions and was able to redirect the incoming requests to another URL, basis on some conditions. Following is the code. function handler(event) { var request = event.request; var headers = request.headers; if request.uri == '/assets/1.jpg'{ var newurl = 'https://instagram.com/media/1.jpg' var response = { statusCode: 302, statusDescription: 'Found', headers: { "location": { "value": newurl } } } return response; } return request } However, this redirects it to the newURL. What I'm looking for is not a redirect, but the following 1) when the request is made to my server CDN, ie `mydomain.com/assets/1.jpg`, the file `1.jpg` should be served from the **Instagram** server, whose value is the `newURL` in the above code snippet. This should be done without changing my domain URL (in the address bar) to Instagram. 2) The following requests to `mydomain.com/assets/1.jpg` should be directly served from the cache, and should not be routed again to Instagram. Any help in this regard is highly appreciated.
0
answers
0
votes
19
views
asked 3 days ago

Cloudfront invalidation request fails: "CloudFront encountered an internal error."

When HTML pages are updated, I programmatically request invalidations from AWS Cloudfront. Occasionally, the invalidation request takes a number of seconds, and gives an error, reading (in part) ``` Server error: `POST https://cloudfront.amazonaws.com/2020-05-31/distribution/(mydistribution)/invalidation` resulted in a `503 Service Unavailable` response:\n<?xml version="1.0"?>\n<ErrorResponse xmlns="http://cloudfront.amazonaws.com/doc/2020-05-31/"><Error><Type>Receiver</Type (truncated...)\n ServiceUnavailable (server): CloudFront encountered an internal error. Please try again. - <?xml version="1.0"?>\n<ErrorResponse xmlns="http://cloudfront.amazonaws.com/doc/2020-05-31/"><Error><Type>Receiver</Type><Code>ServiceUnavailable</Code><Message>CloudFront encountered an internal error. Please try again.</Message></Error><RequestId>(myrequestid)</RequestId></ErrorResponse> ``` This seems to be an internal error from AWS Cloudfront, and it appears to be happening more recently. The [AWS Cloudfront documents](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/http-503-service-unavailable.html) do not mention this error, nor how to handle it. The origin server is responsive and does not show any additional errors when an invalidation is being requested. It does not seem to be under heavy load. I think this is a bug with Cloudfront; but I have no paid support in order to report it. What should my next steps be?
2
answers
1
votes
38
views
asked 9 days ago