1
votes

I have setup a CloudFront origin pull server. It allows me to set a domain name, which I have. This works.

But I don't want the whole domain to be the origin. I want

mydomain.com/folder/subfolder

to be the origin. Also, the cloudfront distribution is CNAMEd to a cdn, which is setup via DNS to cloudfront. This seems to work.

So, basically, instead of this URL:

xyz.cloudfront.net/folder/subfolder/1.jpg

I want this instead:

cdn.mydomain.com/1.jpg

Currently I have achieved, via CNAME and origin pull:

cdn.mydomain.com/folder/subfolder/1.jpg

The question is: on CloudFront how do I setup an origin pull from a folder, not from the main domain name?

2

2 Answers

3
votes

The accepted answer is out of date. This is possible using the "Origin Path" setting in AWS which will rewrite the request to a sub-folder on the origin:

http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/distribution-web-values-specify.html#DownloadDistValuesOriginPath

2
votes

I am not aware of a way to do this cloudfront. However, you create a virtual host at your origin for subfolder.example.com and have it's root directory be the directory you mentioned. Then you could set subfolder.example.com as your origin for the default cache behavior.