Google Answers Logo
View Question
 
Q: How to generate subdomains automatically ( No Answer,   2 Comments )
Question  
Subject: How to generate subdomains automatically
Category: Computers > Programming
Asked by: lifeproducer-ga
List Price: $30.00
Posted: 27 Apr 2004 04:43 PDT
Expires: 27 May 2004 04:43 PDT
Question ID: 336891
My company operates an online service which provides Web page building functions.
Now we wants to add new feature giving different subdomains to the
members' web pages.
Because the number of members is about 120,000, manual configuring is
not the solution.

Let me give you an example.
1) We have domain name such as '123.com'.
2) Someone joined 123.com with account 'abcd'.
3) He get his own direcory in our Web server such as /htdocs/members/abcd/.
   (It's url become 'http://www.123.com/members/abcd' 
    and we currently redirect 'http://www.123.com/abcd' to this url.)

4) And he should get the subdomain 'abcd.member.123.com'. (How can we
implement this???)

About our service environment : Solaris, Oracle, Apache, Tomcat, Java, php, ...

I want to know how to implement generating subdomains automatically.
If any source codes are available, that will be helpful.

Clarification of Question by lifeproducer-ga on 28 Apr 2004 20:30 PDT
Thank you, gouravjain and okrogius.

I think that adding each entries for our members in httpd.conf makes
httpd.conf too heavy and degrade the performance of Web server.

By the way, I found interesting page that would be helpful.
 "Dynamically configured mass virtual hosting"
http://httpd.apache.org/docs/vhosts/mass.html 

I am thinking about how to implement this method to our Web server.
Answer  
There is no answer at this time.

Comments  
Subject: Re: How to generate subdomains automatically
From: gouravjain-ga on 28 Apr 2004 07:35 PDT
 
Hi lifeproducer,

Basically your soultion is to have virtual domains, you need to create
one virtual domain for each of your user in your apache conf file
/etc/httpd/conf/httpd.conf.

This virtual domain will point the request of 'abcd.member.123.com' to
'http://www.123.com/members/abcd'.

You can add the following line in your httpd.conf file to make a virtual domain.

<VirtualHost www.123.com>
ServerAdmin webmaster@abcd.123.com
DocumentRoot /www/docs/abcd.123.com
ServerName abcd.123.com
ErrorLog logs/abcd.123.com-error_log
TransferLog logs/abcd.123.com-access_log
</VirtualHost> 

You can write script in perl or some other language to add the
following entry for all the users you have. If you need the help in
that then please do write to me.

Gourav Jain
Subject: Re: How to generate subdomains automatically
From: okrogius-ga on 28 Apr 2004 17:37 PDT
 
Alternatively there is one opther option which may be easier to
implement under apache (assuming that since you brought up /htdocs/) -
wildcard subdomains. You can add:


ServerAlias *.example.com

In your virtual section of your apache configuration file. Then if
someone goes to 116354654653136496841351.example.com they just get
your default page, rather then a 404.

Finally, make your default page dynamic (PHP or ASP would do fine) to
check the domain the page is being accessed under. If the domain isn't
wwww.example.com or the like, the page can instantly redirect them to
the user's page.

For an example of this try yaxay.com. You can go to [member].yaxay.com
and get a user's profile page (e.g. test.yaxay.com).

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy