Declaring multiple ports for the same VirtualHosts

The question is somewhat ambiguous, but I’ll try to help.

If you want the same virtualhost to listen on multiple ports, then you do this:

Listen 80
NameVirtualHost *:80

Listen 8080    
NameVirtualHost *:8080

<VirtualHost *:80 *:8080>
  ServerName some.domain.name
  ServerAlias some.other.domain.name
  ....
</VirtualHost>

Generally speaking you don’t define multiple name-based VirtualHosts of the same domain name, unless you need to use a different protocol.

For SSL name-based virtualhosts you have to be extra careful: by definition there can not be multiple certificates on the same IP:Port, so, to avoid certificate errors it would have to be a wilcard certificate, covering all served domain names.

Leave a Comment