I've got quite a big VirtualHost definition which I don't want to duplicate just so the site will also run over HTTPS.
Here's what I want to do:
<VirtualHost *>
ServerName example.com
<If port=443>
SSLEngine on
SSLCertificateFile ...
SSLCertificateKeyFile ...
SSLCertificateChainFile ...
</If>
(other config)
</VirtualHost>
Is there some way to do this?
Am I missing some other method of not duplicating the config?
The current stable version of the Apache(2.2) doesn't have that feature, but the 2.4 does have the IF directive.
You have to create two VirtualHosts for now, but you can set some stuff through environment or apache global variables and use that in your virtualhost config (setting the documentroot for example). This way if you want to change that you can do it with just one line of modification.
Of course, you can use include to do something like this:
ps: SNI will be mainstream years before the IPv6 adaptation. All of the mainstream browser support it already assuming you are on a supported OS.
edit: as fooquency spotted you can't put SSLEngine On to an If block so my answer is wrong.
No. You can move most things to the Global config and inherit it in the VirtualHost.
This was answered in another question. Use an Include statement. Worked like a charm for me:
Serve http (port 80) and https (port 443) on same VirtualHost
For SSL virtual hosts, you either have to use a second port ala
or you have to use separate IPs
There's actaully a very good explanation in the Apache SSL docs http://httpd.apache.org/docs/2.0/ssl/ssl_faq.html
Search down for "Why can't I use SSL with name-based/non-IP-based virtual hosts?"