Creation of Sub during Top (ie. webmail)

So, I have a task that I’m trying to set myself up on, and I figured I’d get some help. I’ve been using Virtualmin for about 3 days now and I finally have almost everything set up just how I want it. One thing I noticed was that webmail.domain.tld points to Usermin. I’ve figured out how to change that to, say, Roundcube via the URL redirect under the New Virtual Host template configuration.

I want to instead though keep users within the webmail.domain.tld sub-domain during their interactions with Roundcube.

I’ve been able to have it work by keeping my webmail client in a directory under the top-server. (ie: www.domain.tld/webmail). I have my redirect from webmail.domain.tld pointing to here perfectly fine, and I’m positive I can have it point to webmail.domain.tld if I created a sub-server for it as well.

But having to create a webmail sub-server for each new domain would be tedious. So I figure, why not try and just do it all during the initial creation. I foresee two possible methods of getting this to work. Having the top-server template automatically create the virtual-host for the webmail.domain.tld as well as automatically adding a webmail directory under the home for the new server. (ie. public_html / public_webmail or simply webmail).

Or, a less attractive way is just to have each new top-server create a sub-server at the same time.

Unfortunately, my experience with getting in-depth with apache and such limited, as well as Virtualmin obviously since I’ve had only a few days with it.

Any ideas?

Edit: Just wanted to note I’m using the GPL Virtualmin. As it doesn’t specifically allow me to run the Roundcube installation script, I have one I made to automatically copy, set permissions, and all that fun junk after I make a new virtual host. Just copies all of it into the www.domain.tld/cubemail directory. If I can get one of the above methods to work, I’d instead have it copy over to the webmail.domain.tld.

Update: So, I found out that if I simply add in my Roundcube files to the /etc/skel directory, it basically makes my copy script null and void as it’ll just add the webmail files to any new vhost that’s created. I have it set to where Roundcube will be installed to the home directory along side public_html. All that’s left to do now is figure out how to make a sub-domain automatically create during the top-domain’s creation.


Well, before we look into that further, I want to verify that I can’t talk you out of doing that :slight_smile:

One of the more robust setups you can do for webmail is to create one setup under one Virtual Server… such as in as you mentioned – and to have all users redirect there.

With that – you can then setup an SSL certificate if/when you choose to get one, and secure the information there with the encrypted connection.

Then, you can have all your users domains, such as webmail.users_domains.tld, redirect to that one primary instance,

With that – what you have is one installation of RoundCube, meaning the amount of maintenance you have to do is light. You can secure it with SSL if you wish. And it’s incredibly simple to setup, all you need to do is modify the URL that is used for the “webmail” redirect in the Apache section of the Server Template.