Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a web server with full root access, which hosts 3 domains. They are on the same IP and managed via VirtualHost files running apache2.

I would like to add SSL capability to one of them, i.e. be able to access the same site via

I have tried everything I found online, but most of them result in apache not serving any content at all.

I'd be glad for any help on how to configure my system to support this.



share|improve this question
Hi guys. I'm trying to do the exact same thing but my other virtual hosts (the ones that I DON'T want HTTPS access for) are still trying to process connections. I've even put "SSLEngine off" in the individual vhost sections... what am I missing here? – Mike B Dec 19 '09 at 6:13

You have to add to apache conf

NameVirtualHost x.x.x.x:443

with your ip, and then the virtual host

<VirtualHost x.x.x.x:443>
  SSLEngine on
  SSLCertificateFile /etc/apache2/ssl/cert.pem
  SSLCertificateKeyFile /etc/apache2/ssl/key.pem
  SSLCertificateChainFile /etc/apache2/ssl/ca.crt

  # ...
share|improve this answer
thank you very much, I had tried this - it hadn't worked before, but I think I also fixed some inconsistency with my other conf files. – user15093 Jul 31 '09 at 0:29

What you're asking for is impossible. SSL is a separate layer that encapsulates your HTTP session, and it occurs before the HTTP session has begun. At this point, it's not possible for Apache to determine which hostname you are trying to access the server by.

You can only use IP-based virtual hosts with SSL.

For more information see this section of the Apache SSL/TLS FAQ.

Edit: Sorry, I misread your question. I assumed you wanted SSL for all of your domains. However, if you look at the same FAQ, the solution to your question is there as well. You need to explicitly specify the ports for your HTTP based NameVirtualHosts.

share|improve this answer
Thanks, it works now. The only unintended side effect is that: also goes to but I guess I can live with that for now. – user15093 Jul 31 '09 at 0:30
Incidentally, it is possible to have multiple SSL-secured named virtual hosts on a single IP address - I do it on my website - but it produces all sorts of warnings in the Apache logs, and certificate warnings in the browser. I certainly wouldn't recommend it for a production site that needs to look clean. – David Z Jul 31 '09 at 4:58
I believe you can get away with it if you use wildcard certificates, but that's certainly not a recommended practice. Also, as mentioned in the guide, you can also do it if you run the sites on different ports. eg: domain-a:443, domain-b:444 – Kamil Kisiel Jul 31 '09 at 7:37
Actually SSL virtual hosting of multiple domains can be done using the Server Name Identification feature. Later versions of Apache 2.2.12 onwards allow multiple hosts on different domain names on the same IP and port, there are some limitations on which clients support SNI though. – BenM Sep 2 '09 at 22:11

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.