I am hosting my website on amazon web services. I use a beanstalk application and have an A-record that directs the address www.domain.com to the beanstalk. I also have the same domain but with a .org at the end. I also created an A record that points the domain.org to the same beanstalk application. This works. The problem is that I will buy a ssl certificate for the domain.com and therefore I need the user to be directed to the domain.com when he/she enters domain.org. I tried adding a CNAME record for the domain.org address with the value domain.com. The result is that the user ends up in the correct page but the address in the url bar is domain.org which might cause a problem since the certificate is for domain.com.
DNS cannot do any redirection. That's purely HTTP-level material. You would need to configure your .org vhost to do that, e.g. on apache:
<VirtualHost *:80>
ServerName www.domain.org
RedirectPermanent / http://www.domain.com
</VirtualHost>
Your CNAME is basically pointless. All it does is point a hostname at another hostname, which causes your DNS resolver to fetch the IP of that "another host". It then uses that IP as the IP for the original name. e.g.
domain.org -> CNAME pointer -> domain.com -> a.b.c.d
which then does an HTTP request to the a.b.c.d IP with
Host: domain.org
in the http request header.
You can use Amazon S3 to do this.
Create an S3 bucket called domain.org
Enable Static Web Hosting on the new bucket by choosing "Redirect all requests to another host name"
Set domain.com or www.domain.com as that other domain
If you are using Route53 for your DNS, you can create an Alias record for domain.org to point to your bucket. If you are not using Route53, then create a CNAME to your bucket's public URL.
You can easily do similar things for domain.com -> www.domain.com if you are using Route53.
Related
I'm using AWS route53 as my DNS server.
I have an A Record pointing a webserver for the sub-domain www and CNAME for the root "#" subdomain which points to the www sub-domain, so when I try to get mydomain.com or www.mydomain.com I should get the same result and It works fine in Godaddy DNS and NameCheap DNS servers but in route53 the www record works fine but the # doesn't work and I have to type the full www.mydomain.com for me to get the site back.
In this situation, you don't need to include the # symbol when creating record sets for your domain.
According to the docs,
If you're creating a record that has the same name as the hosted zone, don't enter a value (for example, an # symbol) in the Name field.
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
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.
So I have a domain whose nameservers are pointed to AWS Route 53. My site is hosted on an EC2 instance and is reachable but only resolves to site.com, even if you input www.site.com. I'm curious how to get the site to resolve to www.site.com. I have under Route53 for my domains hosted zone 2 additional record sets outside of NS and SOA:
A site.com EC2 Elastic IP
CNAME www.site.com EC2 public DNS
I can reach the site using both site.com and www.site.com, but it will always resolve as site.com. Is there a way to make it so that if I enter either, it resolves to www.site.com?
At first, both should be A record set.
A site.com EC2 Elastic IP
A www.site.com EC2 Elastic IP
And need redirect setting in your web server (nginx, apache, ..) as following. (Source: How To Redirect www to Non-www with Nginx on CentOS 7)
Redirect non-www to www
If you want redirect users from a plain, non-www domain to a www
domain, add this server block:
server {
server_name example.com;
return 301 $scheme://www.example.com$request_uri;
}
Save and exit. This configures Nginx to redirect requests to "example.com" to
"www.example.com". Note that there should be another server block that
defines your www web server.
I'm currently hosting an S3 bucket with a static website, I'm using an SSL certificate via certificate manager that covers *.domain.com. Visiting the site www.domain.com results in a secure website, however simply going to domain.com does not even though the A record for domain.com points to www.domain.com through Route 53. The specific error message states that the site can't provide a secure connection, my question is, is the DNS not setup correctly to point domain.com to www.domain.com or is it because the SSL certificate is only for *.domain.com and not domain.com.
Secure: https://www.adambarlowlaw.com/
Insecure: https://adambarlowlaw.com/
Pointing domain.com to www.domain.com just has the effect of two separate records that both end up pointing to the same IP address. Lots of people mistake this sort of DNS pointer as a browser redirect, but that is not the case.
You are focusing on the DNS setup, but it is the SSL certificate that is incorrect. Since the server has both domain.com and www.domain.com pointing at it, the server needs to be able to serve both of those domains. You have configured the SSL certificate to work for *.domain.com but not domain.com.
When you request an SSL certificate you need to request two domains domain.com and *.domain.com