user606521
user606521

Reputation: 15424

Custom domain for s3 bucket?

I have S3 bucket called "mybucket". Files from there are available under following links:

  1. mybucket.s3.amazonaws.com/path/to/file.jpg
  2. s3.amazonaws.com/mybucket/path/to/file.jpg

I need custom domain for files served from s3. I added DNS CNAME record pointing to from images.example.com to s3.amazonaws.com (also tried images.example.com -> mybucket.s3.amazonaws.com).

In both cases when I try to GET images.example.com/mybucket/path/to/file/jpg (or images.example.com/path/to/file.jpg) I get S3 error like

Bucket 'images.example.com' does not exist

Is there any workaround for this or I have to change bucket name to images.example.com?

Upvotes: 29

Views: 41893

Answers (2)

nmfzone
nmfzone

Reputation: 2903

From what I've experienced, you just need to set the CNAME with name images and the value is mybucket.s3.amazonaws.com (your bucket location). You don't need to rename your bucket. Old but gold.

Upvotes: 1

Frederick Cheung
Frederick Cheung

Reputation: 84114

You need to change the bucket name. The virtual hosting docs specifically say (in the "Customizing Amazon S3 URLs with CNAMEs" section)

The bucket name must be the same as the CNAME

Upvotes: 32

Related Questions