0

I've set up an S3 Bucket that I want to use as a CDN but with my own subdomain.

For example, myfiles.mydomain.com.

So, I set up a Cloudfront web distribution that points to the bucket named "myfiles-mydomain-com", added a certificate for myfiles.mydomain.com and deployed it.

It all works nicely. I can hit urls such as https://myfiles.mydomain.com/somefile.zip and it loads up in the browser with a valid certificate.

EXCEPT...

The browser seems to redirect and then display the S3 bucket URL to the file. Something like: https://myfiles-mydomain-com.s3.us-east-2.amazonaws.com/somefile.zip

Can this be configured to keep the requested URL instead of exposing the S3 Bucket URL?

2
  • That should be the default. You shouldn't be seeing the s3 url at all... Did you forget to update the dns to point to the cloudfront distribution, instead of the s3 bucket? – KHobbits Nov 25 '20 at 13:32
  • I generally diagnose these sorts of issues by using the 'curl' command, with some flags to make it a bit more verbose. Something like curl -vvvv https://website, and see what the response is. – KHobbits Nov 25 '20 at 13:33
0

In most cases when you select the S3 bucket in the Cloudfront wizard it will select the 'global' URL for the bucket.

This happened to me a few days ago and the way that I fixed it was to put the region-specific URL in the origin field. View the images below for more information.

  1. Check which 'zone' or 'region' your bucket is hosted in. Checking the S3 bucket region

  2. Change the bucket origin URL for the S3 bucket in the Cloudfront console. Changing the origin S3 bucket URL

You can change the S3 origin URL by clicking the edit button in the 'Origins' tab.

Let me know if you would like me to clarify anything.

Hope this helps.

Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.