1

In Apache2, I'd like to separately define my SSL-related stuff once, and in a separate file from the rest of the configuration. This is mostly a matter of taste, but it also allows me to include the rest of the configuration in my automatic deployment process.

I.e.: current situation:

# in file: 0000-ourdomain.com.conf (number needs to be low)
<VirtualHost xx.xx.xx.xx:443>
    # SSL part
    SSLEngine on
    SSLCertificateFile ....crt
    SSLCACertificateFile ...pem
    SSLCertificateChainFile ...intermediate.pem
    SSLCertificateKeyFile ....wildcard.ourdomain.com.key
    SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown

    ServerName www.ourdomain.com
    ServerAlias ourdomain.com

    # the actual configuration, as found for xx.xx.xx.xx:80, repeated
</VirtualHost>

I'd like

# in file: 0000-ssl-stuff
<VirtualHost xx.xx.xx.xx:443>
    # SSL part
    SSLEngine on
    SSLCertificateFile ....crt
    SSLCACertificateFile ...pem
    SSLCertificateChainFile ...intermediate.pem
    SSLCertificateKeyFile ....wildcard.ourdomain.com.key
    SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown

    ServerName www.ourdomain.com
    ServerAlias ourdomain.com
</VirtualHost>

# in file: ourdomain.com.conf
<VirtualHost xx.xx.xx.xx:443>
    # the actual configuration, as found for xx.xx.xx.xx:80, repeated
</VirtualHost>

Unfortunately, this does not seem to work. Apache SSL fails, though it does not give an error message at reload or syntax-check.

My best found workaround is to us an Include directive from the 0000-ssl file.

Many thanks!

  • what's wrong with the include directive? – DTest Jun 26 '11 at 13:27
1

You can create a separate file using the include directive. Your 443 vhost would be:

# in file: ourdomain.com.conf
<VirtualHost xx.xx.xx.xx:443>
    # the actual configuration, as found for xx.xx.xx.xx:80, repeated
    ServerName www.ourdomain.com
    ServerAlias ourdomain.com

    Include conf/vhosts/ourdomain.ssl.conf
 </VirtualHost>

and in conf/vhosts/ourdomain.ssl.conf:

# SSL part
SSLEngine on
SSLCertificateFile ....crt
SSLCACertificateFile ...pem
SSLCertificateChainFile ...intermediate.pem
SSLCertificateKeyFile ....wildcard.ourdomain.com.key
SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown

A couple things. First, the include path is relative from the ServerRoot (ie, /usr/local/apache, not relative to the file that included it.

Second, the ourdomain.ssl.conf file does not repeat the VirtualHost directive for xx.xx.xx.xx:443. That's already been handled by the including Vhost.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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