You need one NameVirtualHost
per criteria, it tells Apache how it will triage incoming requests. If you want name-based virtual hosting on port 80, you only need
NameVirtualHost *:80
Any HTTP client connecting on port 80 will be triaged along the 'Name:'
HTTP header, matching a ServerName or ServerAlias in on of the <VirtualHost *:80>
nodes (or the first defined vhost for the same critera if not match is found).
Most of the time you only need two name-based virtual hosting rules : on for port 80, on for port 443 (the latter only really making sense with SNI / Server Name Indication). This is usually done in an automatic manner where the port 443 and *:433 named-based virtual hosting is activated if mod_ssl is activated :
NameVirtualHost *:80
Listen 80
<IfModule mod_ssl.c>
NameVirtualHost *:443
Listen 443
</IfModule>
In your case, it seems you relyon the usual IP/port-based virtual hosting. In this case every app will need the same code:
Listen 800x
<VirtualHost *:800x>
ServerName app1
[...]
</VirtualHost>
And here the NameVirtualHost
is not needed since you only have one virtual host per port. The
ServerName
is also mostly irrelevant, it will be used by Apache to refer to the vhost in errors.