#!/bin/sh
#
# Configure Apache for FBX.

echo "Configuring Apache..."

# enable miscellaneous modules.
a2enmod rewrite

# enable SSL
a2enmod ssl

# enable mod_alias for RedirectMatch
a2enmod alias

# enable mod_headers for HSTS
a2enmod headers

# setup freedombox site
cat > /etc/apache2/sites-available/fbx.conf <<'EOF'
##
## Enable HSTS, even for subdomains.
##
Header set Strict-Transport-Security "max-age=31536000; includeSubDomains" env=HTTPS

##
## Redirect traffic on home to /plinth as part of turning the machine
## into FreedomBox server.  Plinth then acts as a portal to reach all
## other services.
##
RedirectMatch "^/$" "/plinth"
EOF

a2ensite fbx
a2ensite 000-default
a2ensite default-ssl

echo "Done configuring Apache."
