amazon web services - Multiple Cloudfront Origins with Behavior Path Redirection -
i have 2 s3 buckets serving cloudfront origin servers:
example-bucket-1 example-bucket-2
the contents of both buckets live in root of buckets. trying configure cloudfront distribution route or rewrite based on url pattern. example, these files
example-bucket-1/something.jpg example-bucket-2/something-else.jpg
i make these urls point respective files
http://example.cloudfront.net/path1/something.jpg http://example.cloudfront.net/path2/something-else.jpg
i tried setting cache behaviors match path1 , path2 patterns, doesn't work. patterns have exist in s3 bucket?
yes, patterns have exist @ origin.
cloudfront can prepend path given origin, not have capability of removing elements of path.
if files in /secret/files/
@ origin, have path pattern /files/*
transformed before sending request origin setting "origin path."
the opposite isn't true. if files in /files
@ origin, there not built-in way serve files path pattern /download/files/*
.
you can add (prefix) not take away.
a relatively simple workaround reverse proxy server on ec2 instance in same region s3 bucket, pointing cloudfront proxy , proxy s3. proxy rewrite http request on way s3 , stream resulting response cloudfront. use setup , has never disappointed me performance. (the reverse proxy software developed can check multiple buckets in parallel or series , return first non-error response receives, cloudfront , requester).
or, if using s3 website endpoints custom origins, use s3 redirect routing rules return redirect cloudfront, sending browser unhandled prefix removed. mean request each object, increasing latency , cost somewhat, s3 redirect rules can set fire when request doesn't match file in bucket. useful transitioning 1 hierarchical structure another.
http://docs.aws.amazon.com/amazons3/latest/dev/howdoiwebsiteconfiguration.html
Comments
Post a Comment