Apache2 conditional section based on port

Posted by Waleed Hamra on Server Fault See other posts from Server Fault or by Waleed Hamra
Published on 2013-06-28T09:41:27Z Indexed on 2013/06/28 10:22 UTC
Read the original article Hit count: 431

Filed under:
|
|
|
|

I don't know much about if statements in apache configuration, and I'm wondering if I can have a section of the configuration applied only if the request is received on a certain port.

In short, this is about SSL. I have name based virtual hosts, I can make a configuration for port 80, then duplicate it all for port 443, and add the relevant SSL configurations.

But this seems redundant. I was wondering if i can have something like:

<VirtualHost *:80 *:443>

and then I can put:

<IfModule mod_ssl.c>
    SSLEngine on
SSLCertificateFile ...
SSLCertificateKeyFile ...
SSLCACertificateFile ...
</IfModule>

inside an if statement that checks if connection is on port 443... or is such thing impossible? the server supports SNI, and I don't have any worries from non-SNI compliant browsers.

© Server Fault or respective owner

Related posts about apache2

Related posts about ssl