<VirtualHost *:80>
    ServerName api.datanet.lencraftserver.de

    DocumentRoot /var/www/datanet

    Alias /.well-known/acme-challenge/ /var/www/datanet/.well-known/acme-challenge/
    <Directory "/var/www/datanet/.well-known/acme-challenge/">
        Options None
        AllowOverride None
        Require all granted
    </Directory>

    RewriteEngine On
    RewriteCond %{REQUEST_URI} !^/.well-known/acme-challenge/
    RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

<IfModule mod_ssl.c>
<VirtualHost *:443>
    ServerName api.datanet.lencraftserver.de

    DocumentRoot /var/www/datanet/sources

    <Directory "/var/www/datanet/sources">
        Options Indexes
        AllowOverride None
        Require all granted
        Header set Access-Control-Allow-Origin "*"
    </Directory>

    SSLEngine on
    SSLCertificateFile /etc/letsencrypt/live/api.datanet.lencraftserver.de/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/api.datanet.lencraftserver.de/privkey.pem
</VirtualHost>
</IfModule>
