Can I have domain-wide wildcard DNS?

Hello,

I’m coding an application the lets people attach their custom domains to it without my manual intervention or messing with httpd.conf.

So I need a method very similar to the method described by Google at the following URL: How do I use a custom domain name on my blog? - Blogger Help… Except I’m not Google, so I may switch hosting provider anytime and the IPs will be completely changed.

That will cause a HUGE problem since it means I have to get everyone to update their domain CNAME settings which is impossible without severe downtime.

So how can I have the domains pointed to something fixed like ns1/ns2.mydomain.com?

Your help would be greatly appreciated.

No. CNAME domains point to other domains, not to IPs. So I can have in my DNS


mydomain.com IN CNAME yourdomain.com

So regardless if the IP of yourdomain.com changes, mydomain.com will still point to it. That’s the whole point of CNAME :slight_smile:

From an Apache point of view, a CNAME is the same as a normal domain, so you can just add a new VirtualHost for the CNAME, or add a ServerAlias to existing VirtualHost and then run apache2ctl graceful to let Apache reload the configuration without actually rebooting.

Thanks but why Google uses IP addresses instead of yourdomain.com then?

Using an IP address avoids an extra DNS lookup, but Google knows its IPs won’t change as it is in charge of its own network infrastructure.

Thanks for the clarification Karl.

Now regarding what’s said above:

From an Apache point of view, a CNAME is the same as a normal domain, so you can just add a new VirtualHost for the CNAME, or add a ServerAlias to existing VirtualHost and then run apache2ctl graceful to let Apache reload the configuration without actually rebooting.
Does that mean I have to add a new VirtualHost or ServerAlias for each new account I create from my application that has a custom domain or this is to be done only once?

Hi,

There are a couple of ways of doing it:

  1. ServerAlias each time

  2. Only have a single site on an IP address, then whenever Apache loads up that IP it’s always going to be your content regardless of the domain used - but that’s going to depend on your hosting company.

You’d be better off going with option 1 IMHO.

Thanks,

AFAIK there are two ways to about this

  1. Create a default host and let (PHP?) application running on that host determine what host was called when it runs, or
  2. Like you say, create a VirtualHost or ServerAlias for every new subscription

Method 1 is easier, method 2 is faster.

To be honest, I’ve never actually done this myself; this is just theory from the manual.

Edit:

Karl beat me to it! :slight_smile:

I should add that we have customers doing both methods that I mentioned - One using a ServerAlias setup with several hundred domains, the other uses a static IP for their site and goes with that method (basically the VirtualHost gets all traffic for that IP). Both work very well, the 1st is obviously more portable as it doesn’t rely on you having a dedicated IP.

Thank you very much for your invaluable inputs. I went with the dedicated IP solutions and it’s working.

One last concern. Why Google asks to create 4 CNAME records instead of only one?

Because google uses the CNAMEs for Mail servers (MX records), for which you can have multiple with different priorities for load balancing and other purposes. See MX record - Wikipedia, the free encyclopedia
AFAIK there is no such system for A records.

But here they are talking about attaching the domain to Blogger, not email: How do I use a custom domain name on my blog? - Blogger Help