11

I have www.mydomain.com pointed at an Azure Website.

www.mydomain.com --- CNAME --- mydomain.azurewebsites.net

When I visit www.mydomain.com, everything works fine. This is good.

Problem is, mydomain.com doesn't work. Azure only allows the www subdomain.

In some nameservers, I use a FWD Record to forward the root to the www, and this works fine. My current name server (zoneedit.com) does not have this FWD Record.

Is there a DNS Record that we can use to forward the root domain to the www subdomain?

  • 2
    ZoneEdit has a "WebForward" which will do this. – Michael Hampton Nov 1 '14 at 0:06
  • @MichaelHampton Perfect. We used @ | StealthForward | http://www.example.com – Shaun Luttin Nov 1 '14 at 0:16
  • That's great. It essentially does what I described (points to a real IP, that is a web server that just redirects with an HTTP 300-series to www.domain.com). – DTK Nov 1 '14 at 0:37
15

Unfortunately, this is a well-known shortcoming of the DNS protocol. There is no record type defined within the DNS standards that will allow you to alias the apex of a domain. Many people assume that CNAME records can be used to accomplish this but there are technical reasons why they cannot.

Many DNS providers implement custom (read: fake) DNS record types to try and address this shortcoming. Behind the scenes, these fake records implement custom behavior in that company's software using a combination of synthesized A records and webserver redirection to accomplish your desired goal. FWD is one of these, much like the WebForward that Michael directed you to in the comments.

6

Summary: In short, you can't have the record you want, and your DNS host is doing things The Right Way.

Explanation: It is a violation of the DNS standadards to have a CNAME (alias record / forward record) at zone apex (the empty name at the front of the zone).

The reason for this is a CNAME record cannot have the name portion conflict with any record except a DNSSec record. In a typical zone, a CNAME record at zone apex would collide with at least the SOA and NS records (and likely several others). While some DNS servers will allow this, it is a Bad Thing, and can cause hard to diagnose failures (not to mention will not work if you move hosting of the zone to a standards-compliant DNS server, such as anything BIND-based).

Either have A records at zone apex (they can be a simple web server that just throws an HTTP 302 to www). If you can get static IP numbers for your Azure server instances, put an A record for each at the apex of your zone, and create a single CNAME record called "www" that points to the apex record.

As an example :

 

$ORIGIN example.com.

@    IN  SOA   ns1.example.com.  admin@example.com. (
                                 101 ;
                                 172800 ;
                                 900 ;
                                 1209600 ;
                                 3600 ; )
@    IN  NS    ns1.example.com.
@    IN  NS    ns2.example.com.
@    IN  A     123.234.1.123
@    IN  A     123.234.1.124
@    IN  A     123.234.1.125
ns1  IN  A     123.234.1.126
ns2  IN  A     123.234.1.127
www  IN  CNAME example.com.
  • 5
    IMO: It's not worth it to endlessly reiterate why CNAME apexes don't work. If the user asks why they don't work, we have a canonical answer for that with RFC references. (full disclosure: I wrote it) If they don't ask about it, it's best to stick with answering the question as phrased. – Andrew B Nov 1 '14 at 1:32
  • Thank you. I should have looked for a canonical answer. I'll keep in mind that for next time. – DTK Nov 1 '14 at 2:10
2

Some protocols have standards for DNS record types, other than A records, for finding the service. SMTP with it's associated MX records is a good example of this. There are no defined DNS record types for HTTP. It's likely that your prior DNS/registrar provider had either an HTTP redirect or reverse proxy service.

In order to accomplish your goal you'll need to setup a webserver (virtual host) to do an HTTP 301 or 302 redirect from one hostname to the other, setup a reverse HTTP proxy, setup independent virtual hosts, or use virtual host aliases so the same webserver instance will respond to both A names.

0

If you want an answer specific to Azure you need to create another CNAME record pointing to awverify.mydomain.azurewebsites.net like this

www.mydomain.com --- CNAME --- awverify.mydomain.azurewebsites.net

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.