How to overcome root domain CNAME restrictions?

前端 未结 8 764
失恋的感觉
失恋的感觉 2020-12-04 05:23

We are hosting many web applications for our customers. As is obvious they want to use their own domains to refer to those applications, usually they want that any user tha

相关标签:
8条回答
  • 2020-12-04 05:55

    CNAME'ing a root record is technically not against RFC, but does have limitations meaning it is a practice that is not recommended.

    Normally your root record will have multiple entries. Say, 3 for your name servers and then one for an IP address.

    Per RFC:

    If a CNAME RR is present at a node, no other data should be present;

    And Per IETF 'Common DNS Operational and Configuration Errors' Document:

    This is often attempted by inexperienced administrators as an obvious way to allow your domain name to also be a host. However, DNS servers like BIND will see the CNAME and refuse to add any other resources for that name. Since no other records are allowed to coexist with a CNAME, the NS entries are ignored. Therefore all the hosts in the podunk.xx domain are ignored as well!

    References:

    • http://tools.ietf.org/html/rfc1912 section '2.4 CNAME Records'
    • http://www.faqs.org/rfcs/rfc1034.html section '3.6.2. Aliases and canonical names'
    0 讨论(0)
  • 2020-12-04 06:03

    I see readytocloud.com is hosted on Apache 2.2.

    There is a much simpler and more efficient way to redirect the non-www site to the www site in Apache.

    Add the following rewrite rules to the Apache configs (either inside the virtual host or outside. It doesn't matter):

    RewriteCond %{HTTP_HOST} ^readytocloud.com [NC]
    RewriteRule ^/$ http://www.readytocloud.com/ [R=301,L]
    

    Or, the following rewrite rules if you want a 1-to-1 mapping of URLs from the non-www site to the www site:

    RewriteCond %{HTTP_HOST} ^readytocloud.com [NC]
    RewriteRule (.*) http://www.readytocloud.com$1 [R=301,L]
    

    Note, the mod_rewrite module needs to be loaded for this to work. Luckily readytocloud.com is runing on a CentOS box, which by default loads mod_rewrite.

    We have a client server running Apache 2.2 with just under 3,000 domains and nearly 4,000 redirects, however, the load on the server hover around 0.10 - 0.20.

    0 讨论(0)
  • 2020-12-04 06:04

    I don't know how they are getting away with it, or what negative side effects their may be, but I'm using Hover.com to host some of my domains, and recently setup the apex of my domain as a CNAME there. Their DNS editing tool did not complain at all, and my domain happily resolves via the CNAME assigned.

    Here is what Dig shows me for this domain (actual domain obfuscated as mydomain.com):

    ; <<>> DiG 9.8.3-P1 <<>> mydomain.com
    ;; global options: +cmd
    ;; Got answer:
    ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 2056
    ;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 0
    
    ;; QUESTION SECTION:
    ;mydomain.com.          IN  A
    
    ;; ANSWER SECTION:
    mydomain.com.       394 IN  CNAME   myapp.parseapp.com.
    myapp.parseapp.com. 300 IN  CNAME   parseapp.com.
    parseapp.com.       60  IN  A   54.243.93.102
    
    0 讨论(0)
  • 2020-12-04 06:06

    The reason this question still often arises is because, as you mentioned, somewhere somehow someone presumed as important wrote that the RFC states domain names without subdomain in front of them are not valid. If you read the RFC carefully, however, you'll find that this is not exactly what it says. In fact, RFC 1912 states:

    Don't go overboard with CNAMEs. Use them when renaming hosts, but plan to get rid of them (and inform your users).

    Some DNS hosts provide a way to get CNAME-like functionality at the zone apex (the root domain level, for the naked domain name) using a custom record type. Such records include, for example:

    • ALIAS at DNSimple
    • ANAME at DNS Made Easy
    • ANAME at easyDNS
    • CNAME at CloudFlare

    For each provider, the setup is similar: point the ALIAS or ANAME entry for your apex domain to example.domain.com, just as you would with a CNAME record. Depending on the DNS provider, an empty or @ Name value identifies the zone apex.

    ALIAS or ANAME or @ example.domain.com.

    If your DNS provider does not support such a record-type, and you are unable to switch to one that does, you will need to use subdomain redirection, which is not that hard, depending on the protocol or server software that needs to do it.

    I strongly disagree with the statement that it's done only by "amateur admins" or such ideas. It's a simple "What does the name and its service need to do?" deal, and then to adapt your DNS config to serve those wishes; If your main services are web and e-mail, I don' t see any VALID reason why dropping the CNAMEs for-good would be problematic. After all, who would prefer @subdomain.domain.org over @domain.org ? Who needs "www" if you're already set with the protocol itself? It's illogical to assume that use of a root-domainname would be invalid.

    0 讨论(0)
  • 2020-12-04 06:06

    My company does the same thing for a number of customers where we host a web site for them although in our case it's xyz.company.com rather than www.company.com. We do get them to set the A record on xyz.company.com to point to an IP address we allocate them.

    As to how you could cope with a change in IP address I don't think there is a perfect solution. Some ideas are:

    • Use a NAT or IP load balancer and give your customers an IP address belonging to it. If the IP address of the web server needs to change you could make an update on the NAT or load balancer,

    • Offer a DNS hosting service as well and get your customers to host their domain with you so that you'd be in a position to update the A records,

    • Get your customers to set their A record up to one main web server and use a HTTP redirect for each customer's web requests.

    0 讨论(0)
  • 2020-12-04 06:11

    Sipwiz is correct the only way to do this properly is the HTTP and DNS hybrid approach. My registrar is a re-seller for Tucows and they offer root domain forwarding as a free value added service.

    If your domain is blah.com they will ask you where you would like the domain forwarded to, and you type in www.blah.com. They assign the A record to their apache server and automaticly add blah.com as a DNS vhost. The vhost responds with an HTTP 302 error redirecting them to the proper URL. It's simple to script/setup and can be handled by low end would otherwise be scrapped hardware.

    Run the following command for an example: curl -v eclecticengineers.com

    0 讨论(0)
提交回复
热议问题