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

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

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.

share|improve this question
Why don't you define two virtual hosts, one on port 80 and one on port 443? – Vilelm Jun 28 '13 at 9:58
Yeah, that's what I do now... I was just wondering if there's a less redundant way of doing it – Waleed Hamra Jun 28 '13 at 10:06
1… this answered my question – Waleed Hamra Jun 29 '13 at 8:40

Your Answer


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

Browse other questions tagged or ask your own question.