httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gillis J. de Nijs" <gil...@jink.net>
Subject Re: [users@httpd] if statement and ssl directives (apache 2.4)
Date Wed, 06 Dec 2017 09:56:08 GMT
Hi Adam,

Simplest, in my opnion, is simplest to read and parse for a human.

What's wrong with:

## One VirtualHost that does everything
<VirtualHost *:443>
    ServerName www.comptoir-hardware.com

    SSLEngine on
    SSLCertificateFile /etc/ssl/certs/comptoir-hardware.com.crt
    SSLCertificateKeyFile /etc/ssl/private/comptoir-hardware.com.key
    SSLCACertificateFile  /etc/ssl/certs/comptoir-hardware.com.ca

    DocumentRoot ...
</VirtualHost>

## Redirect to main VirtualHost
<VirtualHost *:443>
    ServerName new.comptoir-hardware.com
    ServerAlias comptoir-hardware.com
    ServerAlias comptoir.co
    ServerAlias www.comptoir.co

    SSLEngine on
    SSLCertificateFile /etc/ssl/certs/comptoir-hardware.com.crt
    SSLCertificateKeyFile /etc/ssl/private/comptoir-hardware.com.key
    SSLCACertificateFile  /etc/ssl/certs/comptoir-hardware.com.ca

    Redirect / https://www.comptoir-hardware.com/
</VirtualHost>

## Redirect http to https main VirtualHost
<VirtualHost *:80>
    ServerName www.comptoir-hardware.com
    ServerAlias new.comptoir-hardware.com
    ServerAlias comptoir-hardware.com
    ServerAlias comptoir.co
    ServerAlias www.comptoir.co

    Redirect / https://www.comptoir-hardware.com/
</VirtualHost>

Cheers,
Gillis

On Wed, Dec 6, 2017 at 10:10 AM, Adam Cecile <acecile@le-vert.net> wrote:

> Hi,
>
> I'm trying to achieve a simplier vhost configuration using if statements
> but httpd refuses to start when I put SSL related directive inside the if
> block:
>
>
> <VirtualHost *:80 *:443>
>   ServerName www.comptoir-hardware.com
>   ServerAlias www.comptoir-hardware.com
>   ServerAlias new.comptoir-hardware.com
>   ServerAlias comptoir.co
>   ServerAlias www.comptoir.co
>
>   <If "req('Port') == '443'">
>     SSLEngine on
>     SSLCertificateFile /etc/ssl/certs/comptoir-hardware.com.crt
>     SSLCertificateKeyFile /etc/ssl/private/comptoir-hardware.com.key
>     SSLCACertificateFile  /etc/ssl/certs/comptoir-hardware.com.ca
>   </If>
>
>   <If "req('Host') != 'www.comptoir-harware.com'">
>     RedirectMatch (.*) http://www.comptoir-hardware.com$1
>   </If>
>
> </VirtualHost>
>
>
> Can you confirm there's a way to do what I want ? Can you see what's wrong
> ?
>
> Thanks in advance,
>
>
> Adam.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>

Mime
View raw message