<VirtualHost *:5080>
    UseCanonicalName off
    UseCanonicalPhysicalPort default
    ServerName gpaas.net
    ServerAlias *.gpaas.net

    DocumentRoot /srv/admin/htdocs

    RewriteEngine On
    RewriteCond %{REQUEST_SCHEME} =http
    RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R=permanent,L]

    <Location />
        AuthType Basic
        AuthName "Authenticate using your instance id and password"
        AuthUserFile ${CUSTOMER_DIR}/var/admin/.htpasswd
        Require valid-user
    </Location>

    Alias /vhosts/ /srv/data/web/vhosts/
    <Directory ${CUSTOMER_DIR}/web/vhosts/>
        Options Indexes FollowSymLinks
        AllowOverride All
        AddHandler proxy:unix:/srv/run/php/admin.sock|fcgi://localhost .php
    </Directory>

    Alias /log/ /srv/data/var/log/
    <Directory /srv/data/var/log>
        Options Indexes FollowSymLinks
        ForceType text/plain
        Header set X-Content-Type-Options nosniff
    </Directory>

    <Directory /srv/admin/htdocs>
        Options Indexes FollowSymLinks
        AllowOverride None
        AddHandler proxy:unix:/srv/run/php/admin.sock|fcgi://localhost .php
    </Directory>

    # FIXME: this should not be enabled for instances other than php5
    <Location /php-status-www>
        SetHandler proxy:unix:/srv/run/php/www.sock|fcgi://localhost
    </Location>
    <Location /php-status-admin>
        SetHandler proxy:unix:/srv/run/php/admin.sock|fcgi://localhost
    </Location>
    <Location /server-status>
        SetHandler server-status
    </Location>

    <IfModule mod_info.c>
        <Location /server-info>
            SetHandler server-info
        </Location>
    </IfModule>

    <LocationMatch ^/gitweb/$>
        Redirect "/gitweb/" "/cgit/"
    </LocationMatch>

    ScriptAlias "/cgit/"            "/opt/cgit/bin/cgit.cgi/"
    Alias       "/cgit.css" "/srv/admin/htdocs/css/cgit.css"
    Alias       "/cgit.png" "/srv/admin/htdocs/images/logo_gandi.png"
    Alias       "/cgit.ico" "/srv/admin/htdocs/favicon.ico"
    <LocationMatch ^/cgit>
        Options +ExecCGI
    </LocationMatch>
</VirtualHost>
