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.
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
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.
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 lineIncludeOptional /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 mainhttpd.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.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.