# make apache listen to the right ports and bind it to the ips you want it to listen on:

Listen 10.1.1.1:80
Listen 10.1.1.1:443
Listen 10.1.1.2:80
Listen 10.1.1.2:443

# SSL can't do name based virtualhosting, only ip based, so no need for them here
# make the http ports name based virtualhosts:

NameVirtualHost 10.1.1.1:80
NameVirtualHost 10.1.1.2:80


# define a catch-all virtualhosts for non-listed servernames.
# this site could have a page saying: "No site configured at this address"

<VirtualHost 10.1.1.1:80>
  ServerName 10.1.1.1.domain.com
  DocumentRoot /path/to/catchall
</VirtualHost>

<VirtualHost 10.1.1.2:80>
  ServerName 10.1.1.2.domain.com
  DocumentRoot /path/to/catchall
</VirtualHost>


# now the real virtualhosts:

<VirtualHost 10.1.1.1:80>
  ServerName www.A.com
  DocumentRoot /path/to/www.A.com
</VirtualHost>

<VirtualHost 10.1.1.1:80>
  ServerName sub.A.com
  DocumentRoot /path/to/sub.A.com
</VirtualHost>

# next ip

<VirtualHost 10.1.1.2:80>
  ServerName www.B.com
  DocumentRoot /path/to/www.B.com
</VirtualHost>

<VirtualHost 10.1.1.2:80>
  ServerName sub.B.com
  DocumentRoot /path/to/sub.B.com
</VirtualHost>


# SSL hosts:

<VirtualHost 10.1.1.1:443>
  ServerName secure.A.com
  DocumentRoot /path/to/secure.A.com
  # SSL options, like certificates
</VirtualHost>

<VirtualHost 10.1.1.2:443>
  ServerName secure.B.com
  DocumentRoot /path/to/secure.B.com
  # SSL options, like certificates
</VirtualHost>
  • No labels