#{{ ansible_managed }}

WSGISocketPrefix /var/run/retrace
WSGIDaemonProcess retrace user=retrace group=retrace processes=5 threads=3

WSGIScriptAliasMatch ^/manager(/.*)?$ /usr/share/retrace-server/manager.wsgi
WSGIScriptAliasMatch ^/ftp(/.*)?$ /usr/share/retrace-server/ftp.wsgi
WSGIScriptAliasMatch ^/settings$ /usr/share/retrace-server/settings.wsgi
WSGIScriptAliasMatch ^/create$ /usr/share/retrace-server/create.wsgi
WSGIScriptAliasMatch ^/metrics$ /usr/share/retrace-server/metrics.wsgi
WSGIScriptAliasMatch ^/stats$ /usr/share/retrace-server/stats.wsgi
WSGIScriptAliasMatch ^/checkpackage$ /usr/share/retrace-server/checkpackage.wsgi
WSGIScriptAliasMatch ^/[0-9]+/?$ /usr/share/retrace-server/status.wsgi
WSGIScriptAliasMatch ^/[0-9]+/delete$ /usr/share/retrace-server/delete.wsgi
WSGIScriptAliasMatch ^/[0-9]+/log$ /usr/share/retrace-server/log.wsgi
WSGIScriptAliasMatch ^/[0-9]+/backtrace$ /usr/share/retrace-server/backtrace.wsgi
WSGIScriptAliasMatch ^/[0-9]+/exploitable$ /usr/share/retrace-server/exploitable.wsgi
WSGIScriptAliasMatch ^/[0-9]+/start$ /usr/share/retrace-server/start.wsgi
WSGIScriptAliasMatch ^/$ /usr/share/retrace-server/index.wsgi

<Directory "/var/cache/retrace-server">
    Options Indexes FollowSymLinks
    AllowOverride None
    <IfModule mod_authz_core.c>
        # Apache 2.4
        Require all granted
    </IfModule>
    <IfModule !mod_authz_core.c>
        # Apache 2.2
        Order allow,deny
        Allow from all
    </IfModule>
</Directory>

<LocationMatch "^/(manager(/.*)?|ftp|settings|create|metrics|stats|checkpackage|[0-9]+(/(log|backtrace|delete|exploitable))?)?$">
    WSGIProcessGroup retrace
    WSGIApplicationGroup %{GLOBAL}
    Options -Indexes -FollowSymLinks
    <IfModule mod_authz_core.c>
        # Apache 2.4
        Require all granted
    </IfModule>
    <IfModule !mod_authz_core.c>
        # Apache 2.2
        Order allow,deny
        Allow from all
    </IfModule>
</LocationMatch>

Alias /repos {{ rs_repo_dir }}
<Directory "{{ rs_repo_dir }}">
    Require all granted
    Options Indexes FollowSymLinks
    IndexOptions FancyIndexing
</Directory>
