Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

How do I set up listening for https requests in apache2?

One of my virtual hosts has a form of:

    <VirtualHost *:80>
        ServerName central
        DocumentRoot /var/www4

How should I modify this extract of my virtual-host-config to enable apache to listen to https? I need it because my website is supposed to send https POST requests at login. I've tried changing the opening tag for:

    <VirtualHost *:80 *:443>

..., but it didn't work. Any ideas?

share|improve this question

2 Answers 2

up vote 6 down vote accepted

try this


  SSLEngine On
  SSLCertificateFile /path/to/file.crt
  SSLCertificateKeyFile /path/to/file.key
  DocumentRoot /var/www4/ssl
#   ....

  DocumentRoot /var/www4/nossl/
#   ....
share|improve this answer

The Listen directive is what you want, but be warned, you need to have a dedicated IP for a proper SSL implementation. Using VirtualHosts (your *:80 and *:443 use this) with ServerName and ServerAlias won't work because that information is gathered from data sent after establishing an encrypted connection (the Hostname part of HTTP 2 exchange is how it figures out your virtualhost).

If that doesn't make sense, I'll try to clarify.

share|improve this answer
while it's not documented and not recommended and apache complains in the log files about it, it IS possible to use name-based vhosts with ssl - if and only if all the name-based ssl sites are subdomains of the same domain AND you have a wildcard certificate for that domain. you can even have both name-based and IP-based vhosts on the same apache server. –  cas Aug 6 '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.