Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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!

share|improve this question
    
what's wrong with the include directive? –  DTest Jun 26 '11 at 13:27
add comment

1 Answer 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.

share|improve this answer
add comment

Your Answer

 
discard

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.