Create multiple domains automagically

4 posts / 0 new
Last post
#1 Mon, 10/03/2005 - 22:56
JeremyTinley

Create multiple domains automagically

Howdy,

Is it possible with the current GPL, or with the planned commercial version, to configure Virtualmin to create multiple entries in Apache per domain?

I'm looking to add a mail.domain.com entry which points to their webmail.

Some call it a subdomain, some a new virtual domain with the same parent host, either way, I want to provide new domains with a webmail url as soon as they're setup.

Possible?

Sun, 06/07/2009 - 06:58
JeremyTinley

I love figuring out my own questions.

It's possible through templating. If I create a new template for Webmail, set the Apache directives to be something like:

ServerName mail.${DOM}
DocumentRoot /path/to/webmail
ErrorLog ${HOME}/logs/error_log
CustomLog ${HOME}/logs/access_log common
<Directory /path/to/webmail>
Options Indexes
allow from all
</Directory>

From here, as an admin, I create a new subdomain for the new domain as I create them. The problem is, the above entry doesn't save because:

Failed to save server template : None of the ServerName or ServerAlias directives contain $DOM

Obviously the ServerName does contain $DOM (more correctly, ${DOM}. Smells like a bug to me.

Thoughts?

Sun, 06/07/2009 - 06:58
JeremyTinley

Here's a patch to allow you to do what I described above (ServerName mail.${DOM}). It's just a modification from an eq to a regexp that does the same thing, but tests for it to exist anywhere.

--- /tmp/virtual-server-lib.pl.orig 2005-10-06 19:58:38.101183768 -0500
+++ virtual-server-lib.pl 2005-10-06 20:00:37.341056552 -0500
@@ -1241,7 +1241,7 @@ foreach $d (@dirs) {
$d =~ s/#.*$//;
if ($d =~ /^s*ServerNames+(S+)$/i) {
$gotname++;
- $gotdom++ if ($1 eq '$DOM' || $1 eq '${DOM}');
+ $gotdom++ if ($1 =~ /($DOM|${DOM})/);
}
if ($d =~ /^s*ServerAliass+(.*)$/) {
$gotdom++ if (&indexof('$DOM', split(/s+/, $1))]= 0 ||

Sat, 10/08/2005 - 06:59
Joe
Joe's picture

Hi Jeremy,
That looks like a good patch to me, so I will include it in the next Virtualmin version. You would need to be careful using this capability though, as it would mean that any domain created this way would have no website for www.DOMAIN.com or DOMAIN.com. A better solution may be to create a server with the actual domain name mail.DOMAIN.com ..

--

Check out the forum guidelines!

Topic locked