How to setup CNAME for Amazon S3 at Namecheap - amazon-s3

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).

Related

How can I host my website on an EC2 Server using Apache but host my images on S3 under the same sub domain?

So I have my website hosted on an EC2 server running apache. All works fine and well.
The issue I'm having is that I want my images hosted on S3 (and possibly cached on CloudFront), not on my EC2 server, but want both accessible under the same domain/subdomain.
For example say my website is www.helloworld.com. I want my images to be accessible at www.helloworld.com/images/foobar.png. I want foobar.png to be hosted on S3 and not each one of my EC2 servers though. How can I go about doing this?
Is there and configuration I can do in the AWS console or are there any rewrite rules I can use in Apache? I know I could always just set up a controller that will download the images from S3 and forward them to the user, but this seems wrong to me.
For that you need to put a load-balancer/proxy in front to intercept all requests and dispatch accordingly. That may not be a bad idea anyway (for availability reasons), but a separate host name for images should not be a problem, either (it's not like users will have to see or type those URL).
Using CloudFront, you can have CloudFront receive the initial requests, then based on the path, forward the request to either your EC2 instance or to your S3 bucket.
For example, you could setup the following:
A CloudFront behaviour that upon a path under /images/ would use an S3 origin, and
A default (for everything else) would go to your EC2 instance origin.

AWS: I can't link my route 53 configuration to my S3 bucket

I have 2 route53 hosted zone, let's call them myfirsturl.com and mysecondurl.com.
For both of them, I have created a bucket in S3 named after my domain names. I have verified it multiple times letter by letter.
Both of my buckets have static content, available from the S3 endpoint, with the fine policy etc: the 2 endpoints work perfectly.
The 1st hosted zone has been bought in route53 and when I connect to it, it opens my static website, all is good.
My second domain name has been transferred to Amazon last month, and in route 53 I can find the S3 bucket in the list of targets when I create the recordset, but it doesn't reach the static website
Another point: I have created a WP site a few days ago, behind a load balancer etc, and I linked wp.myfirsturl.com to it: it worked perfectly
I tried the same with wp.mysecondurl.com, to the same load balancer, it never worked.
I can't find any idea has I can't see any difference between my 2 domain name, except where I bought it.
Another difference:
The 1st is something like sometexte.info
The 2nd is something like sometext-othertext.fr
Maybe the hyphen is a problem? (it's not, pertaining to the doc)
Someone has a lead, please?
The bucket must have the same name as your domain or subdomain in Route53. For example, if you want to use the subdomain acme.example.com, the name of the bucket must be acme.example.com. Have a look at this documentation for more information.

How to point Amazon S3 bucket to test subdomain like images.develop.example.com

Currently I'm using Amazon S3 bucket for my website like images.example.com .Today I also built a test subdomain for development purposes and it is served in develop.example.com
Now I want to use Amazon S3 bucket like develop.images.example.com or images.develop.example.com (I don't know which of them is correct)
Is it possible according to S3 restrictions?
Because Amazon says: You must have same bucket name with your subdomain. So I was create a bucket like images.example.com
and my cname record is: images.example.com.s3-website.eu-west-2.amazonaws.com
My webserver is Apache and runs on Ubuntu
How can reach to my images on my development subdomain?
Should I create a new cname record?
Should I do something on my virtual host file?
or what?
To share static content from develop.images.example.com:
Create an Amazon S3 bucket called develop.images.example.com
Turn on static website hosting
Create a Route 53 A record for develop.images.example.com with Alias=YES and point it to your S3 bucket
This is the same process as you would have followed for images.example.com.

Custom domain for s3 bucket?

I have S3 bucket called "mybucket". Files from there are available under following links:
mybucket.s3.amazonaws.com/path/to/file.jpg
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?
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

How do I map multiple domains to the same bucket on 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.