Same FTP, multiple domains

Hi, thank you for Virtualmin.
Is there a way to have a vhost serving multiple domains, each from its own directory, using the same FTP access ?

not sure i understand correctly, but you can have one virtual server and many sub-servers (other domains) under it. then admin/ftp user for main domain/virtual server, has access to all files in /home/user/domains/ too.

1 Like

That’s great, thank you Dimitrist. With Apache vhost you could upload a directory containing directories with the names of the domains you were serving, and it automatically served each domain accordingly.

If you’re happy to make changes to the virtualhost definitions yourself, you can always copy across an existing config with minor alterations, and it will work. Probably sensible to make a separate config file and include that in the main conf.

You’ll need a parent Unix account for the main virtualhost set up in Virtualmin, but if you’re happy to edit the configs directly, you can.

https://stackoverflow.com/questions/29873573/apache-httpd-conf-link-multiple-domains-to-corresponding-subfolders has some examples.

Any wildcard virtualhost declaration will interfere with the default site, web GUI access and webmail, so you’d need to set up specific virtualhost definitions for access to those (or modify the current one).

Do you want to serve multiple subfolders (much easier with a wildcard vhost) or multiple different domains?

Thank you Chris, great to get such a warm, competent and helpful welcome here.
I can adapt to what dimitrist proposed.
I have many different domains with different content, so I’m glad I will not need an FTP account for each. It would be nice to have everything setup automatically when a new domain gets added by uploading a new subfolder named after it, but that’s likely a niche market feature :slight_smile:

1 Like

If this server is solely for this purpose (hosting numerous domains served from the same parent folder), you may like to create a new virutal server template to have Webmin auto-add new virtualhosts with the settings you need.

NB that Virtualmin uses discrete users and groups for all servers, so permissions will come into play here. Using SELinux for overriding ACLs would help you here while keeping security at the max. Otherwise you’ll have to investigate with sub-servers under the same Webmin/Unix user and group, or some dynamic mod_rewrite stuff in a single virtualhost definition.


For custom templates:

Virtualmin > System Settings > Server Templates, then Create a template from the default settings, then select that template and choose Apache Webserver from the dropdown box at the top. You’d put your mod_rewrite stuff in there.

I suggest you create a handful of test domains first, create what you think is a working mod_rewrite and test against an otherwise default setup, otherwise you’ll end up chasing your tail trying to figure out whether it’s your customisations or something else.

(Incidentally, there’s some virtual template management abilities at the prompt: https://www.virtualmin.com/documentation/developer/cli/virtual_server_templates)


How might I approach this if I wanted to arbitrarily numerous domains with a semi-dynamic basedir, or serve content from subfolders in one master ‘site’?

Well, there’s the mod_rewrite way…

Something like a wildcard virtualhost container, and inside that definition, add an adequately secure mod_rewrite ruleset to parse the requested URL and serve from the relevant domain folder.

Be VERY careful of how you do things like parse the Request URL with mod_rewrite. Sloppy regex can allow traversal and downloading of sensitive system files if improperly formatted.

Or create a template for sub-servers, add each one off that and use Virtualmin’s inbuilt site-nesting features to manage it a little more easily. Otherwise you’ll be off to the prompt (or the text editor) to make all changes and you’ll have to forego some of the nice aspects of the web UI.

There’s Unix and Virtualmin user and group permissions to consider as well as Apache security and how best to serve a lot of content through Apache (or NGINX!)

@Joe, @Ilia and the other staff/devs will probably now suggest a far neater method. :wink:


However you do this, before you add many sites to the box, I’d recommend the following to keep Apache config files and structures sane:

  • go to Webmin > Servers > Apache Webserver > click on the small grey cog icon in the title bar, just above the “Global configuration” text - this takes you to the Module Configuration
  • alter the File or directory to add virtual servers to option to be /etc/sites (or similar).
  • update /etc/httpd/conf/httpd.conf to include the line IncludeOptional /etc/sites/*.conf (if not already added by Webmin)
    as the last line; this will dynamically load configs for each virtualhost as they’re created instead of bloating the main httpd.conf file.
  • You’ll also be able to browse/edit each virtualhost’s .conf via Webmin UI once created
  • If using NGINX, a slightly different adjustment is needed for the same effect.
1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.