Customizing Amazon S3 URLs With CNAME

In this Article the technique used for customizing S3 URL is fine but it is not the ideal method for delivery of your content using Amazon S3. Please refer How to Setup CloudFront as Content Delivery Network For S3

Go4Expert.com is showing signs of more powerful server requirement yet again and I am in process of looking for best server offers from ThePlanet but this time I have also started to move images on Amazon S3 specially article images but I wanted s3.amazonaws.com in the URLs to go but could not find any good article on the same but some information here and there and so thought I will share on how you can also go from

Go4Expert Logo

http://imgs.g4estatic.com.s3.amazonaws.com/banner.jpg

To

Go4Expert Logo

http://imgs.g4estatic.com/banner.jpg

With Amazon S3.

I assume that you have an Amazon S3 account and are aware of the process of creating buckets and uploading files to Amazon. If you are not sure of how to do it you can use S3Fox which is a very good Mozilla plug-in to manage your Amazon S3.

First create a bucket in Amazon S3 with exactly the same domain name / sub domain name. I wanted the URL to be imgs.g4estatic.com and so my bucket name in Amazon is also imgs.g4estatic.com.

Now go to your domain DNS. In my case g4estatic.com is registered at GoDaddy and so I go to DNS control for the Domain and setup a new CName for my domain i.e. imgs and target that to the bucket of Amazon s3 i.e. imgs.g4estatic.com.s3.amazonaws.com. Setting the target to s3.amazonaws.com also works but results in extra HTTP redirects.

Wait for the DNS to propagate but for new CName the change is instant. Now upload everything under the bucket and if you allow public read for the uploaded content you will be able to view your uploaded files in the browser.

Note: DNS names are case insensitive, but Amazon S3 can only have lower-case letters and so try to have everything in lower case only.

Sign up for Free Course on How to be an Online Entrepreneur?

Don't wanna sign up but prefer posts delivered to your Inbox?

Not planning to subscribe through Email. Check out the RSS Feed.

  • http://www.vookster.com Laxmana Rao

    Thank you for your reply,

    Simple Question is:

    How to run Amazon S3 with their own domain without Required CNAME etc: https://vookster.s3.amazonaws.com or https://dtgxnog5a4zcn.cloudfront.net.

    I am running HTTPS supporting website for security reason, with custom CNAME HTTPS will not work as you know that.

    Please suggest me how to configure this in cloudfront as well as in my site.

    Regards
    Laxmana Rao G

  • http://www.vookster.com Laxmana Rao

    Sir, how are you?

    After very long time I came back to your website,

    I need your help in below cause.

    Now I have issue in my site, I am using https in my website because of Amazon CNAME my entire website does not working in https.

    I want revert to amazon cdn CNAME to Amazon own domain they having support in https in this cause I need your help how to changing my old CNAME fields to amazon own domains.

    My Cloudfront details:

    Domain Name: dtgxnog5a4zcn.cloudfront.net
    Origin Name : vookster.s3.amazonaws.com
    CNAME : cdn.vookster.com this is my current CNAME in Cloudfront setting please suggest me I need to change this to origin name in my Cloudfront setting or leave it as current setting.

    This is my Amazon s3 original path:
    https://s3-ap-southeast-1.amazonaws.com/vookster/file/pic/user/1.png

    My Amazon s3 bucket name is (vookster)

    I want use Amazon cdn https feature in my site with their own domain like this: https://s3-ap-southeast-1.amazonaws.com/vookster/file/pic/user/1.png

    Please suggest me how to proceed to setup Amazon s3 own domain with https feature.

    Regards
    Vookster

  • Kanasu

    Hi,

    S3
    Bucket Name – http://www.img.mydomain.com

    CNAME(BigRock) :
    Name – http://www.img.mydomain.com
    Value – http://www.img.mydomain.com.s3-ap-southeast-1.amazonaws.com

    I’ve a file in my bucket. It works in

    https://s3-ap-southeast-1.amazonaws.com/www.img.mydomain.com/dummy.jpg

    but not at
    http://www.img.mydomain.com/dummy.jpg

    It gives a 404 ” File or directory not found”

    Thanks,
    Kanasu

    • http://imtips.co/ Shabbir

      Kanasu, CName name should not be http://www.img.mydomain.com but only img. It may vary from your DNS interface though but ideally it should be only the first part of your domain.

      • Kanasu

        I know. I’ve created two CNAMEs. One with just img and the other with http://www.img

        Still, it’s not working.

        • http://imtips.co/ Shabbir

          Kanasu, can you share your exact domain because there is no reason for not working.

  • Ray

    Hi, I am following your advice but seems could not succeed..

    I want the following
    http://liangpai.s3.amazonaws.com/uploadImage/shareImage/2012-10/506dc1ef71dcf.png

    showing as:

    http://imgs.liangpai.me/uploadImage/shareImage/2012-10/506dc1ef71dcf.png

    My S3 bucket name is “liangpai”. On Route 53, I created a new CNAME named “imgs”, the value I entered for it is “liangpai.s3.amazonaws.com”

    After this I don’t see http://imgs.liangpai.me/uploadImage/shareImage/2012-10/506dc1ef71dcf.png

    Can you help?

    Thanks!
    Ray

    • http://imtips.co/ Shabbir

      Ray, your bucket in Amazon S3 should be exactly the same domain name / sub domain name.

  • Ray

    Hi, I am following your advice but seems could not succeed..

    I want the following
    http://liangpai.s3.amazonaws.com/uploadImage/shareImage/2012-10/506dc1ef71dcf.png

    showing as:

    http://imgs.liangpai.me/uploadImage/shareImage/2012-10/506dc1ef71dcf.png

    My S3

  • Soroush Pour

    Great stuff, this was pretty annoying until I read this and figured it out, thanks Shabbir

    • http://imtips.co/ Shabbir

      The pleasure is all mine Soroush

  • http://www.vookster.com Laxmana Rao

    Thanks lot mere bai it’s success now my website is live with amazon S3 with Cloudfront

    do you any internet marketing idea that promot the new sites. etc email marketing, seo, backlinks

    Regards
    Laxmana Rao

    • http://imtips.co/ Shabbir

      Laxmana Read the following Traffic Tips.

  • http://www.vookster.com Laxmana Rao

    ok I contact my host provider they said Subdomain of CName working fine but why I accessing it. it’s not showing Flower.gif image it’s giving error below:
    NoSuchBucketThe specified bucket does not existcdn.vookster.com5BAE85CCE9E1CC87FboJyJ3hGwt5mbfqDZKkGbbA7bqv2Cu8R/4CLteJ4Na1XxeRQT2zs7nmBNGT1KLZ

    the url i try to access the s3 backet
    http://cdn.vookster.com.s3.amazonaws.com/vookster/Flower.gif
    brother what you think problem where ?

    • http://imtips.co/ Shabbir

      Your files are not access to public.

  • http://www.vookster.com Laxmana Rao

    Thanks for you repl

    ok i have setup new bucket as well as cloudfront now my two url working but CName url not working what is the prolem> working urls:
    http://vookster.s3.amazonaws.com/Flower.gif
    http://s3.amazonaws.com/vookster/Flower.gif
    Notworking Cname url is:
    http://cdn.vookster.com/
    http://www.cdn.vookster.com.s3.amazonaws.com/vookster/Flower.gif

    I have add my Cname under my Hosting not in Name.com
    look like this cdn.vookster.com 14400 IN CNAME dtgxnog5a4zcn.cloudfront.net.vookster.com. (last dot automatically add)

    • http://imtips.co/ Shabbir

      The CName answer for cloudfront should be only dtgxnog5a4zcn.cloudfront.net and nothing more.

      • http://www.vookster.com Laxmana Rao

        when add new Cname under my DNS Management that time I am not enter anything after cloudfront url after again I login to DNS manager it showing look like this dtgxnog5a4zcn.cloudfront.net.vookster.com.

        • http://imtips.co/ Shabbir

          May be WHM is doing something.

  • http://www.vookster.com Laxmana Rao

    Hellow Sir,

    Iam new for Amazon S3. I did’t understanding how to setup S3 with ColudFront for my site.

    I register my domain name with Name.com, they saying if you want work the DNS service you should enable our name server without that we are not able to help or ask hosting provider they said.

    What have do I don’t undestand

    iam using for vookster.com script phpfox i ask they also but thier side also no good response please help me to resolve this issue.

    for setup S3 backet as well as cloudfront for my site.

    Status : Waiting for your reply

    Regards
    Laxmana Rao G

    • http://imtips.co/ Shabbir

      Hi Laxmana,

      Let us take one step at a time.

      You have your Amazon S3 bucket setup done and so you should be able to browse through your publicly uploaded images like mine here

      http://imgs.g4estatic.com.s3.amazonaws.com/banner.jpg

      http://vooksterusercontent.vookster.com.vooksterusercontent.s3.amazonaws.com/banner.jpg

      Once this is done you should be able to convert Amazon url to your domain url by creating the CName for

      vooksterusercontent and add the answer as vooksterusercontent.vookster.com.vooksterusercontent.s3.amazonaws.com

      This is all you need and I am not sure what else is required.

      I have few domains in name.com and I have done the same. cdn.imtips.in is what I use here at imtips.co and it works fine in name.com

      • http://www.vookster.com Laxmana Rao

        Thanks for help brother.

        I have setup s3 backet again now two url i can access but CName url not configure well i think. both url is :http://vookster.s3.amazonaws.com/Flower.gif
        http://s3.amazonaws.com/vookster/Flower.gif

        my CName i used as cdn.vookster.com

        I Added DNS CName at my hosting screen shoot http://www.chatfriendz.com/cek.jpg
        but my name.com support say below issue for updating Cname at Name.com :
        Original MS from NAME.com
        Hello,

        The DNS records can only be managed with whoever you have the Name-servers pointed to. In this case your name-servers are pointed to:

        ns1.chatfriendz.com
        ns2.chatfriendz.com

        And therefor you would have to setup the DNS records there.

        If you want to be able to manage your DNS records with us, you would have to use our name-servers. However, if you change your name-servers to our name-servers you would have to setup the DNS records from within to point to your hosting. We can assist you with this, but you would have to obtain the DNS records from your hosting provider in order for us to set them up. If you have any additional questions or concerns, certainly let us know. We would be happy to provide further assistance.

        Regards,

        Henrik
        ——————————–

        Regards
        Laxmana Rao Gedala

        • http://imtips.co/ Shabbir

          If name.com does not manage your DNS you should be doing it where you have it managed.

  • http://www.vookster.com Laxmana Rao

    can please tell how complete setup my CDN on my site
    please have look url
    http://www.chatfriendz.com/untitled3.JPG

  • http://www.vookster.com Laxmana Rao

    First of all Thank you very much for valuable time spend on my issue

    I typed cname field Bucket in S3 as: vooksterusercontent
    so url Cloud Front Generote
    CNAMEs:vooksterusercontent.vookster.com
    Origin Bucket: vooksterusercontent.s3.amazonaws.com

    what should I use in record answer field, the both url look like this : vooksterusercontent.vookster.com.vooksterusercontent.s3.amazonaws.com

    regards
    Laxmana Rao

    • http://imtips.co/ Shabbir

      You have made the simple things complex. CName answer should be your Origin bucket.

  • http://www.vookster.com Laxmana Rao

    hellow Shabbir!

    I would like create cname for my domain for amazon s3
    I registered by domain with name.com when I enter my CName showing error asking to type (Record Answer) please tell me how could I resolve this issue.

    I have screen shoot for the error shows in my dns field
    http://www.chatfriendz.com/untitled1.jpg

    Regards
    Laxmana Rao

    • http://imtips.co/ Shabbir

      Record answer should be your Amazon S3 bucket name in my case it was imgs.g4estatic.com.s3.amazonaws.com

      Ideally you should be using Cloudfront for delivering your S3 data. See http://imtips.co/cloudfront-cdn-s3.html

  • http://hungryeatwhat.com AdrianTeoYC

    Thanks for this tip on aws :)

    • http://imtips.co/ Shabbir

      The pleasure is all mine. :D

  • http://premiumresalerights.com louie

    HI shabbir,
    Thanks for the great post. Does this also work for zip files? I have been looking for solutions on my product delivery with amazon s3.

    thanks,
    louie

    • http://imtips.co/ Shabbir

      Yes it is independent of the type of files.

      • http://premiumresalerights.com louie

        Thanks for that quick response. Do I need to use subdomain or can I just use a folder in a bucket. i.e. mydomain.com.s3.amazonaws.com/folder
        Sorry to bother you so much.Thanks in advance.

        • http://imtips.co/ Shabbir

          Louie, you can use the S3 bucket but using S3 for downloading means more cost and if you can use the Cloudfront for distribution can reduce your cost considerably. See http://imtips.co/cloudfront-cdn-s3.html

        • http://imtips.co/ Shabbir

          You don’t need any sub-domains and can use Amazon URIs directly