How do I map multiple domains to the same bucket on Amazon S3? - amazon-s3

Is it possible to do that? I need to be able to access mydomain.com by typing in my-domain.com in the address bar of the browser?
Now I added a DNS entry:
my-domain.com CNAME mydomain.com
But this doesn't seem to work. I get an 404 not found error.

You can only map a single domain to your S3 bucket. However you could use Cloudfront to do this.
See my answer to another similar question for more information.

We had the same issue and basically I set our CI to publish to two S3 buckets on release. Not ideal but keeps you clear from resetting caches in CloudFront on publish for the short term.

Related

Multiple subdomains for Amazon S3 Bucket?

We are white labelling site so that mysite.com and site.com and site2.com all share the same code base but different front end UI. They use a lot of the same images, including product images, which are hosted on Amazon S3. The s3 bucket name is based off site.com such that the host is:
https://siteDOTcom-new.s3.amazonaws.com/
Now, we don't care what the Amazon S3 url looks like but some clients do, so we're trying to figure out how to do it. We've tried CNAMEs but that didn't work out. Is it possible to have multiple subdomain aliases for the same S3 bucket?
You should look into Amazon Cloudfront for two reasons:
It would allow you to point to the same s3 buckets with different URLs (e.g. http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/CNAMEs.html)
As a CDN, it will give better downloading speeds for people using your site

S3, from deep link to sub domain (bucket)

I would like to redirect a link as www.example.com/test to a bucket called test.example.com on S3. As far as I know, Apache has a file called .htaccess that does the trick. I'm able to redirect from test.example.com to a bucket on S3, but I don't know how to do it with the deep link thing. Is that possible?
It seems there is no way to accomplish that. I have seen many posts describing amazon s3 as a "very simple container". I solved my problem by creating a folder named test on the main bucket (www.example.com) with a html page redirecting to the actual bucket test.example.com. The best solution is to move to an apache container service, but for the moment I want to keep it simple.

How to setup CNAME for Amazon S3 at Namecheap

I am using amazon S3 to host one of my static sites and wanted to link it to my domain name (domainname.co.uk). So I went into namecheap account-all host records and did something like this,
However, It still doesnt work and throws 404 when I go the website url. By the way, under the "www" option, I am using my S3 url like this, conxxxxxxxxxxx.co.uk.s3-website-eu-west-1.amazonaws.com..
Notice the dot in the end, which is automatically added by Namecheap whenever I try to save, even without the dot. I am not sure if that's causing the issue but it just doesn't work for me.
Going directly to my AWS URL works fine, which implies that something is wrong with my CNAME setup.
Anyone know what am doing wrong here? Namecheap support had absolutely no clue either.
You can only use custom CNAMEs for Amazon S3 if the bucket name matches the CNAME.
For example, if your bucket is named:
files.example.com
and is therefore accessible by default at:
files.example.com.s3-website-us-east-1.amazonaws.com.
A CNAME from files.example.com to the full bucket domain name will allow you to use your custom domain.
However, if your bucket name is not exactly the same as the CNAME you are trying to define, it will not work. In your screenshot, you are trying to use www.... as your CNAME, but the (redacted) bucket name does not contain www.. Note that "exactly" includes case-sensitivity; your bucket name must be all lowercase for a CNAME to work.
The full documentation of this feature is here: http://docs.aws.amazon.com/AmazonS3/latest/dev/VirtualHosting.html#VirtualHostingCustomURLs
If you want/need multiple CNAMEs, and/or a CNAME that does not match the bucket name, Amazon CloudFront allows you to specify arbitrary CNAMEs for a deployment.
Its been a while since this questions was asked , but if anyone looking for NameCheap CNAME setup for static website in amazon AWS s3 bucket then please refer screenshot below.
This setup for AWS S3 bucket hosting + NameCheap DNS record is working for me as of Jul 2019.
This setup is for pointing AWS S3 static website endpoint to your custom domain in NameCheap.
Please note if you are using AWS CloudFront SSL certificate then your CNAME record value will be the CloudFront domain name ( not the static website endpoint).

Is it possible to setup DNS for s3 using multiple buckets for a single domain?

Is there a way to use another bucket name when hosting a site (or indeed any content) than just www.example.com.s3-region.amazonaws.com? I want to use multiple buckets so that when I update the site I can rollback a version if problems arrise and so that updates are an atomic switch between site versions. I only want one bucket used for a domain at a time.
I.e. something like
Bucket Names:
www.example.com.bucket1
www.example.com.bucket2
Procedure:
www.example.com currently points to -> www.example.com.bucket1.s3-region.amazonaws.com
New site version is uploaded to www.example.com.bucket2.
Once verified DNS is changed so that www.example.com points to -> www.example.com.bucket2.s3-region.amazonaws.com
This should not work because S3 looks at the hostname of the request (www.example.com) to find out what bucket you're trying to access so the bucket has to have the same name.
But it is possible to achieve what you want with Amazon CloudFront. There are two options:
You can create a single distribution and only update the origin of it (the S3 bucket).
You can create two different distributions and update the DNS settings to point to the desired distribution. You would also need to update the CNAME properties in both of the distributions (remove www.example.com from the old distribution and add it to the new one).

Is there a way to have index.html functionality with content hosted on S3?

Is there a way to make S3 default to an index.html page? E.g.: My bucket object listing:
/index.html
/favicon.ico
/images/logo.gif
A call to www.example.com/index.html works great! But if one were to call www.example.com/ we'd either get a 403 or a REST object listing XML document depending on how bucket-level ACL was configured.
So, the question: Is there a way to have index.html functionality with content hosted on S3?
For people still struggling against this after 3 years, let me add some important information:
The URL for your website (and to which you have to point your DNS) is not
<bucket_name>.s3-us-west-2.amazonaws.com, but
<bucket_name>.s3-website-us-west-2.amazonaws.com.
If you use the first, it will not work as intended, no matter how much you config the Index document.
For a specific example, consider:
http://www-example-com.s3.amazonaws.com/index.html works.
http://www-example-com.s3.amazonaws.com/ fails with AccessDenied.
http://www-example-com.s3-website-us-west-2.amazonaws.com/ works!
To get your true website address, go to your S3 Management Console, select the target bucket, then Properties, then Static Website Hosting. It will show the website URL that will work.
Amazon S3 now supports Index Documents
The index document for a bucket can be set to something like index.html. When accessing the root of the site or a sub-directory containing a document of that name that document is returned.
It is extremely easy to do using the aws cli:
aws s3 website $MY_BUCKET_NAME --index-document index.html
You can set the index document from the AWS Management Console:
You can easily solve it by Amazon CloudFront link. At Amazon CloudFront you could modify the root object. You can download manager here: m1.mycloudbuddy.com/downloads.html.
Since It's been long time, this question being asked, and Amazon S3 changing their Interface. I would like to answer with updated screenshots.
We need to enable 'static web hosting' for S3 to serve as web hosting.
- Go to Properties -> click on static web hosting -> Select 'use this bucket to host a website'
- Enter the index document (index.html by default), error document and redirection rules, if any.
As answered in this answer on Stack Overflow, web hosting link would be: http://bucket-name.s3-website-region.amazonaws.com
I would suggest reading this thread from 2006 (On Amazon web services developers connection). It seems there's no easy solution to this.
Yes. using AWS Cloudfront lets you assign a default file.
you can do it using dns webforwards and cloaking. just forward to the complete path of the index.html
www.example.com forwards to http://www.example.com.s3.amazonaws.com and make sure you cloak the output.