Mixing IP and Name Based Vhosting on a single server.
# Listen Directives. Need to specify the interface so you don't overlap your vhosts.
# You can leave off the the ':<port>' if you want that interface to listen on all ports.
# IE. Listen 123.123.123.123 will make apache listen on all ports for the interface with the ip of 123.123.123.123
Listen 123.123.123.1:80
Listen 123.123.123.2:80
Listen 123.123.123.3:80
Listen 123.123.123.3:443
# IP based
<VirtualHost 123.123.123.1>
ServerAdmin foo@foo.com
ServerName foo.com
ServerAlias www.foo.com
DocumentRoot /var/www/foo.com/html
# Other configs.
</VirtualHost>
<VirtualHost 123.123.123.2>
ServerAdmin blah@blah.com
ServerName blah.com
ServerAlias www.blah.com
DocumentRoot /var/www/blah.com/html
# Other configs.
</VirtualHost>
# Name based.
NameVirtualHost 123.123.123.3:80
<VirtualHost 123.123.123.3:80>
ServerAdmin wooga@wooga.com
ServerName wooga.com
ServerAlias www.wooga.com
DocumentRoot /var/www/html/wooga.com/html
# Other configs.
</VirtualHosts>
<VirtualHost 123.123.123.3:80>
ServerAdmin fubar@fubar.com
ServerName fubar.com
ServerAlias www.fubar.com
DocumentRoot /var/www/html/fubar.com/html
# Other configs.
</VirtualHosts>
# IP based SSL Vhost. Note as of now, you can not really do multiple SSL name based vhosts.
# This is due to the host information not being sent until after the SSL handshake has occurred.
# There are a couple of workarounds. 1. Wildcard Certs which everyone pretty much understands
# nowadays. The issues are that it will mismatch domain.tld and all your other vhosts have to be of
# domain.tld. 2. AltSubject which requires you to configure openssl to deal with. Issues with this is
# that not all browsers support this and older browsers will ignore this.
<VirtualHost 123.123.123.3>
ServerAdmin fubar@fubar.com
ServerName fubar.com
ServerAlias www.fubar.com
DocumentRoot /var/www/html/fubar.com/html
SSLEngine On
# Other SSL and vhost configs.
</VirtualHosts>