views:

117

answers:

2

hi, i'm building a multi-site application where a client must be able to use his own domain (as oppose to just a subdomain). i like to know the different ways to go about it, and what configuration is needed on both end when/if the client wishes to handle email hosting externally.

any reference to lxadmin/hypervm would be helpful too. tx~

edit: i'm running apache; no ssl requirement.

A: 

This is something similar to how blogs in wordpress.com work. xyz.wordpress.com can be mapped to www.xyz.com.

Wordpress MU has the same feature and there are plugins to do it. This link will give you some idea.

Basically I think when ever a client request to map his domain to his site (in subdomain) we add an addon domain and give the details of name servers to the user. Once they are set the redirection should work. I will add more if I find any more useful links.

Shoban
A: 

I'd recommend creating a subdirectory in the apache conf directory. Something like conf/user-domains. Each file in that directory would be named like the user's domain, such as userdomain.com, and would contain the apache directives for that subdomain. Something like (off the top of my head):

<VirtualHost *:80>
   ServerName userdomain.com
   DocumentRoot "/path/to/userdomain.com/htmldocs/"
</VirtualHost>

Assuming you have some web-interface for the user to create those domains, it would store a file with his settings in some known location, such as $webtmp/userrequests/request-XXXYYZ. You'd then have a cron-job that would scan that location for new requests, and create matching files in conf/user-domains.

Oh, and do me a favor, and don't just copy input from the user into the config file - that's a great way to get your server hijacked. Check it first, and untaint it if it's legal. (I'd further recommend you give write-only access to conf/user-domains to a user fakedaemonuser, and run the cron-job as that user.)

EDIT: Forgot to tell you, you'll need to add a directive in apache's main config file (http.conf usually):

Include conf/user-domains/*.conf

Of course, that's assuming all the files you're creating in conf/user-domain/ end in .conf.

scraimer