

Ask HN: managing subdomains cookbook - morbidkk

We have seen webapps like weebly/syanthasite. They allow you to create the webpages and assign you subdomain
Lets say http://morbidkk.weebly.com If you buy your domain they modify DNS settings to point to your pages on its host.
As a example http://www.morbidkk.com fetches contents from http://morbidkk.weebly.com<p>If I have webapp which allows people let design and deploy their travelogue websites; how subdomains are assigned and even new domain redirect(CNAME/redirect) happens.
I need to understand this automation.<p>Lot of people here might have already done this and can laugh out over this question.I am looking for smart way to do this.<p>Any pointers?
======
kitt
Pointer: google for subdomain rewrite

If you are using apache, and mod_rewrite, you can set up rewrite rules for
subdomains.

<http://www.webmasterworld.com/forum92/4640.htm> suggests rewrite rules to
redirect a subdomain to a page/app on the main domain.

Then, use a domain wild card to point everything to your main www.example.com
host (create an A record (HOST) to point * to your IP address).

Now, all example.com subdomains (hosts) will go to the A record IP address,
which will be redirected to the program/pages/urls you expect.

Next, have the customer modify their DNS to point to your IP address. If you
want, you can do the request yourself to their current ISP, to update the
domain's DNS, if they're keeping their email with the ISP. If they don't, and
you're controlling their email, too, go with Google's hosted email.

Now, this unknown domain is coming to your IP address. If you're using apache,
set up the domain to go to the redirected domain. Easy way to do that is to
set up a server alias, or have a virtual host that answers for everything:

<VirtualHost *:80> </VirtualHost>

One way to do it, at least.

------
johns
Wildcard DNS entry. Create an entry for *.example.com that points to your
service and let the code figure it out.

~~~
morbidkk
I checked your site. My friend is looking something like yours for Chess
tournaments.

Now back to my question. how about user's own domain?

Do they need to set it up or it can be configured on our end?

Google creates such entries if you register a domain through their google app
account. How can that be done?

~~~
johns
We have a table with custom domains in it, so when a request comes in, we
check that table first, then the subdomains.

We're currently setting up DNS manually because we don't have that many people
using their own domains, but we could easily automate it if it ever became
burdensome. We give users the choice to let us host their DNS (and then help
them update the nameservers on the domain) or just tell them what IP they need
to point their domain to.

------
senthil_rajasek
Are you asking how <http://www.morbidkk.com> points to
<http://morbidkk.weebly.com> ?

There are a couple of ways you can achieve this,

I use CNAMEs, this would be done by someone who controls the source domain's
DNS, morbidkk.com in the above case.

The other way is to create a direct DNS A record which is not so flexible and
probably not possible in this specific scenario since we are talking sub-
domains, which are typically created as vhosts.

I actually don't understand your travelogue websites question?? Can you please
elaborate?

~~~
morbidkk
I have done it. That is not my question. Lets say I have a webapp travelR.com
and you create your pages senthil.travelR.com and you also buy domain
senthil.com.

How can I automate senthil.com 's pointing to senthil.travelR.com
programatically.

Earlier answer mentioning myDNS helps. up voted

~~~
ra
There's two parts to the question.

1\. How does senthil.com get to my server 2\. How does my server know what to
do with senthil.com

1\. Can only be done by the domain owner. You need to instruct them to either:
a) Point the domain to your nameservers (in which case you'll need to
configure a DNS server, in this case the myDNS suggestion is a good one). or

b) Have the domain owner setup an A record, pointing to our servers IP address
(I assume you already have a dedicated IP - you'll need one).

Question 2, how does your server know what to do with it's traffic?

Well HTTP includes a HOST Header, which represent the hostname the user types
into their URL bar.

You'll need to look for this, and direct them to the appropriate mini-site.

One way, as someone pointed out, is using Apache. So, you could either write
out apache conf files and trigger reloads, or write some code in your app that
looks at this header.

Hope this helps.

------
richesh
[http://www.intridea.com/2008/6/23/subdomainfu-a-new-way-
to-t...](http://www.intridea.com/2008/6/23/subdomainfu-a-new-way-to-tame-the-
subdomain)

------
samt
have not run not such a site myself, so take this with a grain of salt. I
assume that most use a database-backed DNS server like MyDNS, so
adding/removing/etc subdomains is a simple db call.

------
natch
Your examples lend themselves to confusing answers, so I am changing the
examples to use my own examples, which are of course totally clear and
correct.

Here's how the record in your zone file should look:

foo IN CNAME lalala.bigpipe.com.

The above (from foo all the way to .com.) should all be on one line. Note the
. at the end is required.

Now let's say this is the zone file on your web site, googoogaga.com. Now
after this record takes effect, people can point to:

<http://foo.googoogaga.com/>

and they will get files from lalala.bigpipe.com, but their browser address bar
will continue to show them foo.googoogaga.com. Nice, huh?

You do not need to have access to the zone file on bigpipe.com; you only need
to have access to put your content files you are serving onto
lalala.bigpipe.com. Well, that is, unless you are using their content files.

