# Initial HTTP vhost. The router forwards external :80 to the server's :80.
# Copy to /etc/apache2/sites-available/kiln.conf.
<VirtualHost *:80>
    ServerName kiln.spb.ru
    ServerAlias kiln.beer kiln.bar xn--h1adei.xn--90a1af.xn--p1ai

    Alias /.well-known/acme-challenge/ /var/www/kiln-acme/.well-known/acme-challenge/
    <Directory /var/www/kiln-acme/.well-known/acme-challenge/>
        Require all granted
    </Directory>

    RewriteEngine On
    RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/
    RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE]

    RequestHeader set X-Forwarded-Proto "http"
    RequestHeader set X-Forwarded-Port "80"

    ErrorLog ${APACHE_LOG_DIR}/kiln-error.log
    CustomLog ${APACHE_LOG_DIR}/kiln-access.log combined
</VirtualHost>
