Point www subdomain to naked domain instead of bucket name - amazon-web-services

I've got a domain name (example.com) which I've purchased through namecheap. The website is a just static site that I recently decided to switch over to S3. Following the instructions on the aws website I've:
Created two buckets: example.com and www.example.com
Configured the example.com bucket to be a static website and placed my files in it.
Configured the www.example.com bucket to redirect to the example.com bucket
Created a hosted zone for my domain
Placed a type A alias for example.com in my hosted zone that points to my example.com bucket
Placed a type A alias for www.example.com in my hosted zone that points to my www.example.com bucket
Taken the nameservers from the NS record in my hosted zone and in namecheap set my domain to use them.
When I go to example.com it works just as expected. When I go to www.example.com it takes me to my website correctly but it shows www.example.com.s3-website.us-east-2.amazonaws.com as the domain. I haven't been able to figure out how to get it to point to www.example.com instead. Where have I gone wrong?

Configured the www.example.com bucket to redirect to the example.com
bucket
You want the actual redirect url configured in S3 to be https://example.com, not the url of your example.com bucket. Just update that and you should be good to go.

Related

Route 53 : www traffic redirecting to naked domain

These are the steps I followed:
got a new domain name from AWS domain registry. Lets say example.com
Create a certificate with the help of ACM for example.com
My Cloudfront distribution(lets say dXXXXXXXXXX.cloudfront.net) points to a S3 folder (contains some images)
Cloudfront url with aws provided distribution name works fine (lets say: https://dXXXXXXXXXX.cloudfront.net/1.jpeg)
Added example.com as alternate domain in that distribution definition and imported the certificate of example.com in CloudFront
Added one A and one AAA entry in the route53 where source is: example.com and target is:dXXXXXXXXXX.cloudfront.net
7.Added an alias type 'A' entry where source is www.example.com and target is example.com
8.Now when I try to use url: https://www.example.com/1.jpeg , it is showing can't connect to the server of www.example.com where as if I use https://example.com/1.jpeg , it shows the picture.
Please help me here.
You should use CNAME instead of Alias A.
Try this instead
www.example.com CNAME example.com
example.com A Alias <_id>.cloudFront.com

Alias www.example.com to the same example.com on AWS

I have an EC2 instance and i have setup a domain with route53 and an elastic IP so that my domain is poiting to the same address all the time. However, I have a problem because only https://example.com is working but not https://www.example.com. I know there must be a way to route or to create an alias so that www.example.com redirects me to example.com, but i'm not sure how to do it.
To create alias record for what's called naked Domain. You need to set A record to directly the IP address.
Go to Route53,
Create Record Set
Name: www.example.com
Type: A - IPv4 address
Alias: No
Alias Target: x.x.x.x (<-- your IP address for example.com)
AWS Documentation » Amazon Route 53 » Developer Guide » Configuring Amazon Route 53 as Your DNS Service » Working with Resource Record Sets » Supported DNS Record Types
Route53にNaked Domainを設定する方法〜ELBを利用しない場合〜(How to configure Naked Domain for Route53 ~ (without ELB))
If you want to redirect requests for www.example.com to example.com, you could use S3 Static Website Hosting, and the Redirect Requests option.
In this case, you would create a bucket named www.example.com, and in the Properties for the bucket, enable Static Website Hosting, then select Redirect Requests, and set the Target Bucket or Domain to www.example.com. Be sure to record the Endpoint URL. For example, if you created your bucket in us-west-2 the endpoint would be www.example.com.static-website-us-west-2.amazonaws.com.
Next in Route53, Open the zone for example.com, and create a Record Set. In the Name field, enter www (this field should be followed by example.com), set the Type to CNAME - Canonical Name and Alias to No. Next in the Value field, enter in the Endpoint you recorded from the Static Website Hosting section above. Again, if the domain was www.example.com and hosted in us-west-2, this should be www.example.com.static-website-us-west-2.amazonaws.com.

Amazon Cloudfront URL access by only CNAME and not directly

I am hosting a static website on AWS using Amazon S3 + CloudFront + HTTPS.
I need to ensure that the website is opened by only one of the CNAMEs and not the other (non-www). The S3 domain must also be forwarded to the main WWW domain.
How can this be done?
You need to use S3 to redirect the requests.
You will firstly need to create two buckets with the names: www.example.com and example.com and provide appropriate bucket
policies
You will then need to redirect all the traffic from example.com S3 bucket to www.example.com by going into static website hosting
settings. Check out the below settings
Now, you have to setup the CNAME in Route53 such that example.com will translate to www.example.com
Create a distribution for www.example.com and use the alternative CNAME as www.example.com
If I understand you correctly, you can add a CNAME to a CloudFront Distribution from within the CloudFront console. You can also add a CNAME to a CloudFront distribution in Route53 by selecting to add a CNAME, click the Alias=yes radio button and select the relevant CloudFront resource.
See image below for where this is done in Route 53:

S3 Cloudfront - Redirects to the file path

I have configured Cloudfront & S3 to redirect my page such that when the user loads www.example.com, it redirects to https://example.com.
When I load the page for url www.example.com it redirects to https://www.example.com.s3-us-west-1.amazonaws.com/index.html. Any idea what am I missing here? I did generate an SSL cert for both example.com and www.example.com. The cloudfront is updated for both www.example.com and example.com.
For www.example.com
The origin domain name path: www.example.com.s3.amazonaws.com
Origin id is S3-www.example.com
For example.com
The origin domain name path: example.com.s3.amazonaws.com
Origin id is S3-example.com
For S3 bucket: www.example.com is redirected to example.com using static website setting - checking Redirect all requests to another host name
Update
I had two distribution settings. One for www.example.com & another for example.com
The https characters are in red with a exclamation mark. (invalid cert) But the certificates are valid
Yes the bucket is recently created and its in the us-west-2 region.
I also created two route 53 Alias records. One for example.com and another for www.example.com
Each points to its own cloud front distribution.

Amazon AWS static page showing URL as Endpoint

I have a domain address with NameCheap. I followed all of the documentation for setting up a hosted zone with Route 53 for my AWS account. I deployed my website and checked to see if it worked using the endpoint URL. It worked fine. After that, I took the 4 NS urls from the Hosted Zone and mapped them in NameCheap following a tutorial I found online. I chose a Custom DNS for the Name Server and placed the 4 NS urls.
This all worked fine, when I go to my domain: www.example.com it shows my website. However it changes the URL to http://example.com.s3-website-us-east-1.amazonaws.com/
Is there a way to get it to say www.example.com and not the Amazon endpoint?
It appears that this only happens when I go to www.example.com. When I go to example.com, the url stays as example.com and doesn't change to the end point like it does for www.example.com.
Is there a step I missed?
I have 2 buckets: example.com and www.example.com. www.example.com bucket redirects to example.com as described in the AWS tutorial.
http://docs.aws.amazon.com/gettingstarted/latest/swh/getting-started-hosting-your-website.html
You need to create another s3 bucket named www.example.com, and configure it to redirect to example.com.