Using name based virtual hosting with apache2 and SSL
Wednesday, September 24th, 2008One of the things I found when getting my Wordpress installation going was that I wanted to run a seperate subdomain for it, whilst keeping my secure server that I use for developing websites running SSL on port 443.
Normally, to set up virtual hosting, I would add something like this in my site’s config file:
<VirtualHost *>
But to keep the hosts listening on the right ports, you need to add the port number to the wildcard:
<VirtualHost *:80>
Trouble was, when you use the NameVirtualHost directive in apache2, you can’t mix the port numbers.
The solution was found on Friend’s of Bart http://fob.po8.org/comment/reply/289
Simply use
NameVirtualHost *:80
NameVirtualHost *:443
Both in your apache2.conf file. Then in each of your site’s config file, use the explicit port number on the VirtualHost directive:
<VirtualHost *:80>
<VirtualHost *:443>