Is there a way to define an Apache 2 virtual host with a partial ServerName
I have a tool that generates Apache 2 config blocks. I would like what it generates to be independent of whatever the actual ServerName is, but without needing to actually run on/parse the target machine's Apache config.
In other words, what I need is something like this:
<VirtualHost *>
ServerName foobar // <-- no top level domain
...
</VirtualHost>
It seems from reading the docs like the ServerName field must always be the fully qualified domain name, and thus inherently a vhost block cannot be written without knowing the FQDN of the target server. Is that true or is there some workaround?
Yes ServerName
must be real server identification, but can be ip-address as well.
ServerAlias
on the other hand can contain wildcards.
Documentation mentions this.
But it also says that it is not required
If no ServerName is specified, the server attempts to deduce the client visible hostname by first asking the operating system for the system hostname, and if that fails, performing a reverse lookup on an IP address present on the system.