0
votes

I'm trying to set up cloudfront to serve my S3 images. I have one origin working to serve my javascript, css and fonts (coming from heroku).

I created a new origin for my images:

Origin Domain Name: MYBUCKET.s3.amazonaws.com

This was auto-populated by cloudfront. I left origin path blank. Restrict Bucket Access is set to 'No'

The URL from s3 works fine: http://MYBUCKET.s3.amazonaws.com/people/pics/000/000/674/medium/open-uri20150807-28718-re2542?1439005733

Replacing the URL with cloudfront does not: http://CLOUDFRONTURL.cloudfront.net/people/pics/000/000/674/medium/open-uri20150807-28718-re2542?1439005733

I invalidated the cache but no luck. What am I doing wrong?

1
You didn't mention setting path patterns. With multiple origins, you have to specify path patterns so Cloudfront knows which origin to check, for each object.Michael - sqlbot
Thank you so much, It's working! You should submit this as an answer!Ashbury

1 Answers

1
votes

As Michael commented:

If you have multiple origins, you have to log in to cloudfront, click 'Behaviors' and create a behavior with a new 'path pattern'.

In my case assets has my Heroku deploy as the origin. Images for my models come from the s3 bucket.

Precedence   |   Path Pattern    |   Origin
   0         | assets/bootstrap  |  my-heroku-assets
   1         |      people/*     |  my-aws-bucket