Donate

Categories

Advert

XHTML

Valid XHTML 1.0 Transitional

Multiple DNS Names

There are many situations where multiple DNS names for a single IP address that runs a single service are useful. One common example is with business web servers that have both www.example.com and example.com being active, so whichever a customer hits they will get the right content (the last thing you want is for a potential customer to make some trivial mistake and then give up).

Having both DNS names be equal and separate is common. One example of this is the way http://planet.ubuntulinux.org/ and http://planet.ubuntu.com/ both have the same content, it seems to me that planet.ubuntu.com is the more official name as the wiki for adding yourself to the Planet is wiki.ubuntu.com. Another example of this is the way http://planet.debian.org/ and http://planet.debian.net/ both have the same content. So far this month I have had 337 referrals to my blog from planet.debian.org and 147 from planet.debian.net. So even though I can’t find any official reason for preferring one over another the fact that more than 2/3 of the referrals from that planet come from the planet.debian.org address indicates that most people regard it as the canonical one.

In times past there was no problem with such things, it was quite routine to have web servers with multiple names and no-one cared about this (until of course one name went away and a portion of the user-base had broken links). Now there are three main problems with having two names visible:

  1. Confusion for users. When a post on thedebianuser.org referred to my post about Planet Ubuntu it used a different URL to the one I had used. I was briefly worried that I had missed half (or more) of the content by getting my links from the wrong blog – but it turned out that the same content was on both addresses.
  2. More confusing web stats for the people who run sites that are referenced (primarily the bloggers in the case of a Planet installation). This also means a lower ranking as the counts are split. In my Webalizer logs planet.debian.org is in position #5 and planet.debian.net is in position #14. If they were combined they would get position #3. One thing to keep in mind is that the number of hits that you get has some impact on the content. If someone sees repeated large amounts of traffic coming from planet.debian.org then they are likely to write more content that appeals to those users.
  3. Problems with sites that have strange security policies. Some bloggers configure their servers to only serve images if the referrer field in the HTTP protocol has an acceptable value (to prevent bandwidth theft by unethical people who link to their pictures). My approach to this problem is reactive (I rename the picture to break the links when it happens) because I have not had it happen often enough to do anything else. But I can understand why some people want to do more. If we assume that an increasing number of bloggers do this, it would be good to not make things difficult for them by having the smallest possible number of referrer URLs. It would suck for the readers to find that planet.debian.org has the pictures but planet.debian.net doesn’t.

The solution to this is simple, one name should redirect to the other. Having something like the following in the Apache virtual host configuration (or the .htaccess) file for the least preferred name should redirect all access to the other name.

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

In my posts last night I omitted the URLs for the Planet Searches from the email version (by not making them human readable). Here they are:

3 comments to Multiple DNS Names

  • I’ve written an Apache plugin that automatically redirects from any name that is listed in ServerAlias to the ServerName, otherwise leaving the URI intact.

    There is not much difference to using mod_rewrite, minus the potential for typos leading to undesired effects, and that it avoids duplicate information.

    It’s in Debian as libapache2-redirtoservname.

  • Jon

    In the case of planet debian, it was on .net for years prior to being considered an official service and earning a .org, iirc. Using Simon’s module (or achieving the same ends via mod_rewrite) would be a good idea I think.

  • Using mod_rewrite is a little bit like using a caterpillar to kill a mosquito. Just use mod_alias:
    Redirect permanent / http://planet.example.com/
    (and yes, it does redirect suburls)