But that’s impossible!!
HTTPS is just HTTP encapsulated inside an SSL tunnel. Apache’s virtual hosts are a clever “hack” whereby the Host header in the HTTP packet is verified. This alllows a single apache instance on a single IP/Port combination to serve a (not so) infinite number of differentes sites (aka vhosts).
Problem: The SSL tunnel is created before the first HTTP packet gets sent. Apache needs an SSL certificate but doesn’t have a Host header to match, hence cannot choose a virtual host.
Solution
This trick essentially does the matching of the Host header after the SSL connection has been established. How? Via some mod_rewrite magic!
Caveats
Although I said so, it’s not really that magical. There are a few things this trick does not solve.
- The SSL certificate used will be common to all SSL vhosts.
- Certain Apache directives may be common to all SSL vhosts (example: SuExecUserGroup). Basically anything you can’t override in a .htaccess file will be shared amongst vhosts.
(more…)