1

I'm very new to this so bear with me. I have a NameCheap account for DNS, an Amazon AWS Elastic Beanstalk account for hosting, and a Google GSuite account for email.

I want to set up my DNS so traffic from both mydomain.com and www.mydomain.com goes to my AWS site. At first, only www traffic was getting through. Then I added the "@" record below and it started working, but I think it might have broken my email because now I'm not receiving anything. It used to work and I didn't modify any of the MX records.

Type            Host   Value
CNAME Record    @      mydomain-prod.us-east-2.elasticbeanstalk.com.
CNAME Record    www    mydomain-prod.us-east-2.elasticbeanstalk.com.

How do I configure my DNS so traffic from both mydomain.com and www.mydomain.com goes to my AWS site and my email still works?

Edit - I don't think that this question is a duplicate. I'm asking how to make my email work with forwarding my bare domain to www. The linked question doesn't mention email and doesn't answer my question.

adam0101
  • 121
  • 5
  • 1
    You have to use Amazon Route 53 for DNS, and their special nonstandard "ALIAS" record if you want both hostnames to be served by your app. Otherwise, just 301 redirect to www. Namecheap has a [special nonstandard record](https://www.namecheap.com/support/knowledgebase/article.aspx/385/2237/how-to-redirect-a-url-for-a-domain) of its own to do that for you. – Michael Hampton Jan 15 '19 at 22:48
  • What does your MX record point to? – Joe Jan 16 '19 at 03:10
  • 1
    You're right, it's not exactly a duplicate. But [it does explain](https://serverfault.com/q/613829/126632) why you are having the problem, and you should read it carefully to understand what is going on. – Michael Hampton Jan 16 '19 at 03:31
  • @Joe, my MX records point to google's servers for my G Suite account. – adam0101 Jan 16 '19 at 03:32

1 Answers1

3

You cannot have a cname record at your top level domain. This is a violation of RFC1912

2.4 CNAME records

A CNAME record is not allowed to coexist with any other data. In other words, if suzy.podunk.xx is an alias for sue.podunk.xx, you can't also have an MX record for suzy.podunk.edu, or an A record, or even a TXT record. Especially do not try to combine CNAMEs and NS records like this!

Remove the Cname from the top level or @ record and add an a record that points to the ip address of your AWS domain.

Edit: Basically what is happening is you MX records are getting ignored with a CNAME at your top level domain. Most DNS services will not even allow a CNAME at the top level since it will break all other record types at the same level.

Your fix is to set your elastic beanstalk app to have a public ip address and then assign that as an A record to your DNS after removing the cnames. This will restore your email as the MX record will no longer be ignored. AWS

Joe
  • 1,175
  • 1
  • 8
  • 11
  • Do I make an A record for `mydomain.com` or for `www.mydomain.com`? How does the `mydomain.com` traffic get redirected to `www.mydomain.com`? I guess it doesn't matter if it doesn't redirect as long as both urls go to the same server. Just trying to understand. – adam0101 Jan 16 '19 at 15:33
  • DNS will only resolve a URL to an IP address, it does not do the redirecting. If you point both @ and www to the same IP address, then it's up to the server to decide how to handle the request. When you visit a website, you browser will access the server by ip address and then send the url that the client intends to visit to the server. It is then up to the server to decide to either redirect the client to another URL (www in your example) or display a website. This allows one web server to handle multiple websites on the same ip address. – Joe Jan 16 '19 at 16:12
  • So two A records to point each to the IP? Or does just one of them use an A record and the other use something else like a CNAME? – adam0101 Jan 16 '19 at 16:37
  • In your case, you would create 2 A records(one for www and the other for @) both with the same ip address. – Joe Jan 16 '19 at 16:40