Amazon S3: Static Web Sites: Custom Domain or Subdomain
Solution 1
It turns out that to make it work, you cannot just map any arbitrary subdomain to any arbitrary bucket. The fully qualified subdomain name must be the same as the S3 bucket name.
- Suppose the name of your site is static.mydomain.com. Then you need to create a S3 bucket with that same name, named static.mydomain.com.
- Once you configure that bucket as a S3 static web site, it will have a URL assigned to it that looks something like http://static.mydomain.com.s3-website-us-east-1.amazonaws.com.
- Go to your domain host and map your subdomain to the URL from step 2. In enom.com, that meant mapping the host "static" to the address "static.mydomain.com.s3-website-us-east-1.amazonaws.com" as a CNAME record.
Thanks to Uriah and David for suggestions. I eventually got my answer at an Amazon AWS forum.
Solution 2
Make sure that you follow the S3 DNS bucket naming conventions when creating your bucket.
Then:
Enable S3 Website support for the bucket using the AWS Management Console at Properties --> Website
Make sure the files in the bucket have public read permissions
Try the website using the endpoint listed in the Management Console
Setup your CNAME using the listed endpoint (e.g.
www.example.com CNAME www.example.com.s3-website-us-east-1.amazonaws.com
)
Solution 3
This is called Virtual Hosting of Buckets: http://docs.amazonwebservices.com/AmazonS3/latest/dev/VirtualHosting.html
Solution 4
- Create a hosted zone say mydomain.com. You can use a web based UI DNS30.
- Now create a CNAME entry for this hosted zone.
- Add a resource record with following detail Name as "mydomain.com" Type as "CNAME" Value as "mydomain.com.s3.amazonaws.com" TTl as "on your required configuration"
Hope this will also work for static.mydomain.com
Regards-
Udit
Solution 5
How about using a DNS service, like the Route 53 that Amazon provides. Set it up with a CNAME from your sub domain to the public bucket URL. Of course, if your domain company provide CNAME configuration, that could work directly.
Related videos on Youtube
Jay Godse
I am a software developer. My favourite tools are Ruby, Rails, PostgreSQL, Sidekiq, Slim, jQuery, and Ansible. I also have a Github profile.
Updated on July 05, 2022Comments
-
Jay Godse almost 2 years
Amazon.com just announced that one can host static web sites in a S3 bucket. I went to their setup page at http://docs.amazonwebservices.com/AmazonS3/latest/dev/index.html?WebsiteHosting.html and created a bucket for my static web site, and it worked fine. I have an URL of the form http://[my bucket name].s3-website-us-east-1.amazonaws.com/.
However, I would like to point a subdomain that I own (e.g. static.mydomain.com) to my static web site at Amazon S3. Has anybody figured out how to do that?
I appreciate any help you can give me.
-
Ajitesh Singh over 3 yearscheck this out arrayofcode.com/…
-
-
Jay Godse over 13 yearsI did all 4 steps. Step 3 works. The cname in step 4 configures (with enom.com, which does this successfully with other subdomains), but neither hitting my s3 subdomain with a browser nor pinging it work. With heroku.com and blogger.com you have to tell them which of your subdomains is going to be hitting which heroku-app or blogger-blog. S3 static web sites doesn't seem to have this.
-
Uriah Carpenter over 13 years@Jay Godse What's the name of your website-enabled bucket and it's region?
-
Jay Godse about 12 yearsI don't know. You'll have to try it out. Also, you will probably be piggybacked on Amazon's SSL certificate, and not your own.
-
lynks almost 12 yearsyou can actually just point your cname to s3-website-us-east-1.amazonaws.com, it appears to ignore the subdomain and use the HOST http header to specify the bucket. It appears not to matter if the two match, or even if the subdomain is present.
-
plyawn almost 11 years@lynks - you can even drop the region and just go with s3.amazonaws.com
-
plyawn almost 11 years@hnprashanth that's correct (using just S3) you can have up to 10 subdomains pointing to the same resource location with a CloudFront distribution though... check out docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/…
-
Mike_Laird over 7 yearsThis works. AWS states this in an early Intro section, but by the time you go through all the steps, its easy / likely to forget it. It is a better solution than lynks cname solution because AWS now has transaction charges for cname lookups by each user.
-
Rafael over 6 yearsif you point just to s3.amazonaws.com it will redirect to your site WITHOUT the "website" keyword. So if you made it as static, it wont work. At least it didnt work for me.
-
Saeed Taran almost 6 yearswhat if someone else have a bucket with static.mydomain.com name!? then u cant create a bucket with that name because it must be unique.