Multiple Fossil Repositories as CGI at Apache2

ALX 2018-08-09

Apache2 Configuration

<Virtualwww *:80 [::]:80>
   ServerName www.example.org
   Redirect permanent / https://www.example.org/
</Virtualwww>

<IfModule mod_ssl.c>
    <Virtualwww *:443 [::]:443>
        ServerName www.example.org
        DocumentRoot /srv/www/htdocs/example.org/www

        <Directory /srv/www/htdocs/example.org/www>
            Options -Indexes
            DirectoryIndex index.html

            RewriteEngine On
            RewriteRule ^fossil/(.*) /fossil/$1 [L]

            Require all granted
        </Directory>

        ScriptAlias /repos/ /srv/www/htdocs/example.org/www/repos/

        <Directory /srv/www/htdocs/example.org/www/repos>
            Options +ExecCGI
            SetHandler cgi-script

            RewriteEngine On
            RewriteRule !^fossil/ / [R=301,L]

            Require all granted
        </Directory>

        Include /etc/letsencrypt/options-ssl-apache.conf
        SSLCertificateFile /etc/letsencrypt/live/www.example.org/fullchain.pem
        SSLCertificateKeyFile /etc/letsencrypt/live/www.example.org/privkey.pem
    </Virtualwww>
</IfModule>

CGI File /srv/www/htdocs/example.org/www/repos/fossil

#!/usr/local/bin/fossil
directory: /srv/fossil

HTML file /srv/www/htdocs/example.org/www/index.html

<!DOCTYPE html>
<html>
  <head>
    <title>Fossil Repositories</title>
  </head>
  <body>
    <h3>Fossil Repositories</h3>
    <p><a href="/repos/fossil/test1">Test Repository 1</a></p>
    <p><a href="/repos/fossil/test2">Test Repository 2</a></p>
    <p><a href="/repos/fossil/test3">Test Repository 3</a></p>
  </body>
</html>

Your repositories are here

/srv/fossil/test1.fossil
/srv/fossil/test2.fossil
/srv/fossil/test3.fossil