Amazon S3 Static Hosting Custom Domain - amazon-web-services

I'm learning some web development and am using Amazon S3 as a web host with a custom domain from Google domains. I used the guides from the Amazon AWS page and was able to set up the web page but I have a problem with getting the custom domain to work.
For example, Amazon S3 has the endpoint URL to www.example.com.s3-website-us-east-1.amazonaws.com and I want my domain example.com to show up. When I load the page for www.example.com, it loads the page however it still shows the example.s3-website-us-east-1.amazonaws.com when I want it to show the simple example.com instead.
From what I can tell, I need a CNAME, I've set it up as www.example.com -> www.example.com.s3-website-us-east-1.amazonaws.com with permanent redirect (301) and forward path.
Please help!

If anyone was wondering how I got it to work, I ended up using Cloudflare with its free DNS options. I added the DNS servers to google domains and then added two CNAMES:
# -> example.com -> example.com.s3-website-us-east-1.amazonaws.com (for the root)
CNAME -> www -> www.example.com.s3-website-us-east-1.amazonaws.com (for the www redirect)

On the Google side, configure the CNAME record (www) to point to s3.amazonaws.com. (yes, the dot included) ... like this:
... and wait a few minutes.
Make sure your S3 bucket is named: www.yourdomain.com

Related

Redirect to WWW not working in chrome with S3 static website hosting

I have hosted a static website on AWS S3 with a custom domain (purchased from crazy domain). I have obtained SSL certificate from AWS ACM.
I need to redirect bare domain "example.com" to "https://www.example.com".
Following are the steps I have followed so far -
Created 2 buckets on S3 - example.com (Used for redirection) and www.example.com (Used for website hosting)
Created 2 cloudfront distribution -
One with "Origin Domain Name" as "example.com.s3.amazonaws.com" and another with another with "Origin Domain Name" as "www.example.com.s3-website-ap-southeast-2.amazonaws.c
om"
Created CNAME record set on crazy domain with WWW pointing to cloudfront distribution as
Added "A" record set in Route53 for both cloudfront distributions.
When I enter example.com in Firefox and Safari, it is redirecting to https://www.example.com but in Chrome it is showing This site can’t be reached
Can anyone please let me know if there is anything specific I need to do for Chrome?
Finally I have figure it out as -
Added NS record set from Route53 to Crazy domain
Removed CNAME record set with www
Added Web Forward record set in crazy domain

How to redirect route 53 dns to s3 static page

I searched a lot of similar questions and got more confused.
Basically my application is running on https://example.com/login. I have this DNS on route53. Now I want to display the "Under maintenance" page on the same URL.
So I created a static HTML page and hosted it in s3. Now if I am hitting example.com then I can access the static page but when I am hitting https://example.com/login or http://example.com/login I don't see the static page. Now I am having 2 questions:
Can I redirect example.com/login to example.com? so that my static page is visible.
Can I redirect https to HTTP or https://example.com/login to example.com?
I guess for https I have to use CloudFront but still checking if there is any other way?
Even if it's possible, you shouldn't do it. Just use CloudFront with Route53 and ACM and host everything on HTTPS. Here's an article how to do that, but you can find a lot of other ones.
The steps you need:
request a new certificate on ACM (make sure you use the us-east-1 region). Select domain validation, then add the CNAME record to the domain
create a new CloudFront distribution, add the S3 bucket as the origin, select "redirect HTTP to HTTPS", then add the alternate domain name as your domain (example.com) and select the ACM certificate
add an A and an AAAA record in the Route53 hosted zone, make them an ALIAS to the distribution
wait a few minutes and it should work
Using HTTP marks the connection as "Not secure" by the browser and a login form is especially something you want to serve over an encrypted connection. You need to set up CloudFront once, and you can add new files to the S3 bucket.

Change CNAME mapping from Root Domain to WWW on AWS s3?

I'm getting 400 Bad Request and "The specified bucket exists in another region. Please direct requests to the specified endpoint." when going to my domain: http://www.*.com/. I have the CNAME record on namecheap set to: .com.s3-website.us-east-2.amazonaws.com, which works fine when I type it in the browser. It seems like it's going to www..com.s3-website.us-east-2.amazonaws.com instead, (with the www added), because you get the same error if you type that into the address bar. I spoke with namecheap support, and he told me to change the CNAME host to # and delete the url redirect record because "it might be that the configuration of your website requires bare domain name not WWW". That didn't work. I also have namecheaps private email and he mentioned "your Email Service won't work if you have CNAME for the Root Domain". He told me to contact AWS support (I dont have tech support plan) and tell them to "Please contact your Hosting provider to change records from their side from Root Domain to www" and "you should change CNAME mapping from Root Domain to the WWW."
So I'm stumped here. Can anyone help me here? Is there a way to do what he said and will it fix my problem? Thanks.
This error means that you have configured the CNAME record in your DNS server to use the wrong S3 static web site endpoint.
Your CNAME is using us-east-2. In what region is the bucket located?
Go to the Amazon Console.
In S3 bucket properties, click on static web site hosting.
Copy the URL for your web site.
Go to your DNS Server.
Go to the record for www.
Make sure that the CNAME matches the static web site URL.
[EDIT after a series of comments]
If you create a bucket with the name www.hibachiandyou.com then the domain must exactly match the S3 bucket name. If you want to also have a the domain hibachiandyou.com, then you need another bucket with the exact same name. You cannot use DNS redirects to get from one to the other. Use any other convention and it will not work.
The domain apex (hibachiandyou.com) cannot be a CNAME. Amazon Route 53 supports using ALIAS records for the domain apex. I am not aware of any other DNS server that supports ALIAS records. Recommendation, move your DNS servers to Route 53.
You can use a redirect with S3 to redirect one static web site to another web site. Review section 2.3 in this link.
Setting up a Static Website Using a Custom Domain

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.

How do you use Amazon Route 53 to redirect a subdomain to a specific page?

I would like to redirect my subdomain "subdomain.example.com" to a specific page on my site "example.com/specific-page" using Amazon Route 53. Is this possible?
I saw this answer and tried it (Set up DNS based URL forwarding in Amazon Route53) but that appears to only allow you to redirect to root domains, not specific pages on that domain.
Is this possible with Route 53?
Set up Route53 to point to the subdomain. The rest should be handled by your webserver.
For Apache, you can use .htaccess.
For NGINX, I'd set up the server and location blocks accordingly.
I don't believe that this is possible.
You could set up a DNS wildcard, so that *.example.com was mapped to a specific server, and then that server could use something like mod_rewrite to redirect from somename.example.com to example.com/somename.
This is actually fairly simple.
Follow the instructions outlined in the original example, except do not follow step #3.
Instead of following step #3 do this:
In the S3 Properties for subdomain.example.com select Static Website Hosting.
Select the radio button for Redirect all requests to another host name.
In the textbox, enter example.com/specific-page.
Click Save.
Proceed with the rest of the steps as outlined in the original example.
Your bucket should look like this:
You could solve this problem by creating an S3 bucket, enabling the bucket for static web hosting. On the static web hosting tab in the bucket, you can configure a redirect rule, set that redirect rule to https and set the redirect host to the desired address e.g.example.com/blabla
Then go over to Route53, configure a A record for the hosted zone, enable Alias, and point the A record to the S3 bucket endpoint.