Cache behaviour setting, i use
s3/*
to redirect request to s3 folder, but i don't want to place my images under a folder named s3 but right under s3 bucket to redirect like this:
xxxx.cloudfront.com/s3/images/1.png -> bucket_name/images/1.png
not
xxxx.cloudfront.com/s3/images/1.png -> bucket_name/s3/images/1.png
Please help to show me how to config like this.
Origin path CloudFront appends the directory path to the value of Origin domain, for example, cf-origin.example.com/production/images .
You can configure a single CloudFront web distribution to serve different types of requests from multiple origins. For example, your website might serve static content from an Amazon Simple Storage Service (Amazon S3) bucket and dynamic content from a load balancer.
CloudFront delivers your content through a worldwide network of data centers called edge locations. When a user requests content that you're serving with CloudFront, the request is routed to the edge location that provides the lowest latency (time delay), so that content is delivered with the best possible performance.
Amazon CloudFront works with S3 but copies files from S3 to the outer "edge" of Amazon's servers, allowing for fast retrieval. My tests show that it retrieves files in about half the time of S3. There's a slight increase in price from Amazon S3, but not much.
You can do this with lambdas here's the relevant lambda snippet.
exports.handler = (event, context, callback) => {
// this is the request we want to re-map
var request = event.Records[0].cf.request;
// the request has a 'uri' property which is the value we want to overwrite
// rewrite the url applying your custom logic
request.uri = 'some custom logic here to rewrite the url';
// quit the lambda and let the request chain continue
callback( null, request );
};
I don't think this is possible. An Origin Path can redirect to a subdirectory, (eg index.htm
-> production/index.htm
) but CloudFront can't strip out path portions.
See documentation: Origin Path
Some options:
s3
s3/
at the front of your filenames (and actually use the full path)If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With