Im trying to link my domain name to a static website on aws S3
I have 2 buckets set up on S3 one is domain.com and the other is www.domain.com. doamin.com has static website hosting enabled www.domain.com redirects to the domain.com
I can access my index page through: https://s3.us-east-2.amazonaws.com/domain.com/index.html but it doesn't work with this url and I get an access denied message: https://s3.us-east-2.amazonaws.com/domain.com
I have 2 host records both are CNAME:
Host: @ Value: www.domain.com.s3-website-us-east-2.amazonaws.com
Host:www Value: domain.com.s3-website-us-east-2.amazonaws.com.
In my browser it says "site can't be reached" when I have either of those cname values as my url. Also my domain is registered with NameCheap and I can't transfer it to route 53 as it is not old enough. I've never done this before so I really don't understand what I'm doing wrong.
Also my domain is registered with NameCheap and I can't transfer it to route 53 as it is not old enough.
You don't have to transfer it... the registration is locked, but the name server settings should not be... so you can use namecheap as registrar and still use Route 53 as authoritative DNS. And that is what you need to do. (You can transfer the registration to the Route 53 Registrar later, or never. Route 53 provides the two services, registrar and hosting, separately.)
Configure a new hosted zone in Route 53, configure it appropriately, and then change the authoritative nameservers at Namecheap to use the 4 nameservers that Route 53 assigned to your hosted zone.
It isn't possible to use S3 at the root (apex) of a domain that isn't hosted in a Route 53 hosted zone, because a CNAME at @
is simply not a valid configuration. Some people will argue to the contrary, and some DNS providers even allow it, but it is still an entirely invalid configuration. This is why Route 53 introduced Alias A records. They are valid at the apex of a domain, and solve this issue.
You don't need to transfer the domain to AWS. All you need to do is create a hosted zone in AWS route 53. What you're going to do is set up a new DNS configuration inside AWS and then tell your registrar (NameCheap) to use the AWS nameservers.
- Create the hosted zone with your domain name, domain.com
- Create an A record for your domain. On the right side you'll see a radio button "Alias" choose yes, then click into the target box and wait for your bucket to appear under S3 Website endpoints. (More on this below).
- Select your bucket and click create.
- Head over to your registrar, NameCheap and configure the nameservers to use the AWS nameservers in the NS record from your AWS hosted zone.
In order for this to work you need to make sure your S3 bucket is named and configured correctly.
- Your bucket name must match the domain name.
- In the properties tab, you need to enable the static website hosting option and provide your index page.
- In the permissions tab, click on bucket policy, then click the policy generator link at the bottom.
- In the policy generator, select S3 as the type of policy
- Set the principal to *
- set the action to Get Object
- set the ARN to the ARN for your bucket /*. For example arn:aws:s3:::domain.com/ *
- Click Add statement, then generate policy and paste that into the bucket policy and save.
Finally upload your assets and you're done
Needed to have basicDNS on NameCheap and use www.domain.com as my main bucket and have domain.com redirect to the main bucket
来源:https://stackoverflow.com/questions/45271678/domain-name-setup-with-aws-s3-bucket-with-static-hosting