Inconsistent generation of VirtualHost SSL directive for new vhost causes Apache to stop serving existing vhosts

An issue with using Virtualmin to create name-based virtual hosts with SSL support enabled causes Apache to stop serving all other vhosts. The issue is caused by the way Virtualmin generates new VirtualHost directives in the vhost config file. When creating a new virtual host with SSL support enabled, Virtualmin generates two dissimilar VirtualHosts directives:
<VirtualHost *:80>…
<VirtualHost 0.0.0.0:443>…

Note: 0.0.0.0 denotes the real IP address of the web server as detected by Virtualmin

When these directives are written to the new .conf file and Apache is reloaded, the <VirtualHost 0.0.0.0:443> directive takes precedence over all existing <VirtualHost *:443> directives and Apache stops being able to serve the other vhosts.

The issue can be fixed by manually editing the newly created .conf file, changing 0.0.0.0:443 to *:443 and reloading Apache, but this is not a good solution for a production website where there could be dozens or hundreds of vhosts. I do not see any setting in Virtualmin > System Settings > Server Templates > Apache website that could change this behavior for future vhost generation.

One could argue whether a *:port is better or not than a ip-address:port setting, but the point of the matter is that Virtualmin is inconsistent here. If it generates a *:80 setting, it should also generate a matching *:443; if the IP address is used, both settings should include that IP address and wildcard should not be used.

I guess I could edit all existing .conf files and switch from a :80/:443 to ipaddress:80/ipaddress:443 to avoid downtime in the future but do I have to? Has anybody else had the same problem? Is that behaviour a feature or a bug?

Ivan

Are you sure you want this post to be private? It means only me and Eric will ever see it, which virtually guarantees it’ll take longer to get a reply. I’d recommend only marking things private if you’re including sensitive information.

We don’t recommend using wildcard IP like this. But, the behavior you’re seeing is somewhat bug-like; I bet it’s related to the fact that historically you couldn’t host multiple SSL domains on a single IP, and so using a wildcard was an undefined behavior for SSL sites. I guess that’s no longer true, since Apache (and Virtualmin) supports name-based SSL hosts.

If it’s reproducible, file a ticket in the tracker about it with the steps needed to reproduce the problem, and it’ll likely get fixed in the next release.