<VirtualHost *:80>
    ServerName filesharing.ddns.net

    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 filesharing.ddns.net

    ErrorLog ${APACHE_LOG_DIR}/cloud-error.log
    CustomLog ${APACHE_LOG_DIR}/cloud-access.log combined

    ProxyPreserveHost On
    ProxyPass /error/cloud/index.html !
    ProxyPass / http://localhost:1025/ retry=0
    ProxyPassReverse / http://localhost:1025/

    DocumentRoot /var/www/datanet

    <Directory /var/www/datanet>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
    </Directory>

    ErrorDocument 503 /error/cloud/index.html

    SSLEngine on
    SSLCertificateFile /etc/letsencrypt/live/filesharing.ddns.net/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/filesharing.ddns.net/privkey.pem
</VirtualHost>
</IfModule>
