<VirtualHost *:80>
    ServerName photos.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 photos.lencraftserver.de

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

    RewriteEngine On
    RewriteCond %{HTTP:Upgrade} =websocket [NC]
    RewriteRule /(.*)           ws://localhost:1026/$1 [P,L]
    RewriteCond %{HTTP:Upgrade} !=websocket [NC]
    RewriteRule /(.*)           http://localhost:1026/$1 [P,L]

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

    DocumentRoot /var/www/datanet

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

    ErrorDocument 503 /error/photos/index.html

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