# IVLE web application server configuration for Apache 2 with SSL
# Redirect all HTTP requests for normal IVLE to HTTPS
<VirtualHost *:80>
    ServerName ivle.localhost
    RedirectMatch (.*) https://ivle.localhost$1
</VirtualHost>

# Use HTTP for public mode
<VirtualHost *:80>
    ServerName public.ivle.localhost

    <Location />
        Order allow,deny
        Allow from all

        SetHandler mod_python
        PythonHandler ivle.dispatch
        #PythonDebug On
    </Location>
</VirtualHost>

# Use HTTPS for normal IVLE
<VirtualHost *:443>
    ServerName ivle.localhost

    # SSL Engine Switch:
    # Enable/Disable SSL for this virtual host.
    SSLEngine on

    # A self-signed (snakeoil) certificate can be created by installing the
    # ssl-cert package.
    # See /usr/share/doc/apache2.2-common/README.Debian.gz for more info.
    # If both key and certificate are stored in the same file, only the
    # SSLCertificateFile directive is needed.
    SSLCertificateFile    /etc/ssl/certs/ssl-cert-snakeoil.pem
    SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key

    # Public requests should be served by HTTP (Optional)
    # Note: Handing public mode requests with HTTPS may cause certificate 
    # errors unless also signed. Requires mod_rewrite.
    #RewriteEngine   on
    #RewriteCond     %{HTTP_HOST} ^public.ivle.localhost$
    #RewriteRule     ^(.*)$ http://%{HTTP_HOST}$1 [L,R]

    <Location />
        Order allow,deny
        Allow from all

        SetHandler mod_python
        PythonHandler ivle.dispatch
        #PythonDebug On
        PythonOption mod_python.file_session.database_directory /var/lib/ivle/sessions
        PythonOption mod_python.session.cookie_name ivle
    </Location>
</VirtualHost>
