# Apache vhost for kastia.net → HollowCade on 127.0.0.1:3000
#
#   sudo a2enmod proxy proxy_http proxy_wstunnel headers rewrite
#   sudo cp deploy/apache-kastia.net.conf /etc/apache2/sites-available/kastia.net.conf
#   # Or merge the Alias + ProxyPass blocks into your existing HTTPS vhost
#   sudo a2ensite kastia.net
#   sudo apache2ctl configtest && sudo systemctl reload apache2
#   sudo certbot --apache -d kastia.net -d www.kastia.net
#
# IMPORTANT: Certbot creates a separate *:443 vhost — copy the Alias / ProxyPass !
# blocks into BOTH the HTTP and HTTPS VirtualHosts, then reload Apache.
#
# Adjust DocumentRoot / Alias paths if the clone is not /var/www/html

<VirtualHost *:80>
    ServerName kastia.net
    ServerAlias www.kastia.net

    # Optional: direct disk Alias (faster). Play also works via /api/rom/ through Node.
    Alias /roms/ /var/www/html/public/roms/
    Alias /covers/ /var/www/html/public/covers/

    <Directory "/var/www/html/public/roms">
        Options FollowSymLinks
        AllowOverride None
        Require all granted
        Header set Cross-Origin-Resource-Policy "cross-origin"
    </Directory>

    <Directory "/var/www/html/public/covers">
        Options FollowSymLinks
        AllowOverride None
        Require all granted
    </Directory>

    ProxyPreserveHost On
    RequestHeader set X-Forwarded-Proto "expr=%{REQUEST_SCHEME}"
    ProxyPass /roms/ !
    ProxyPass /covers/ !
    ProxyPass / http://127.0.0.1:3000/
    ProxyPassReverse / http://127.0.0.1:3000/

    LimitRequestBody 536870912

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

# After certbot, mirror the same Alias + ProxyPass exceptions in your SSL vhost, e.g.:
# <VirtualHost *:443>
#     ServerName kastia.net
#     ... ssl lines from certbot ...
#     Alias /roms/ /var/www/html/public/roms/
#     Alias /covers/ /var/www/html/public/covers/
#     <Directory "/var/www/html/public/roms">
#         Require all granted
#         Header set Cross-Origin-Resource-Policy "cross-origin"
#     </Directory>
#     <Directory "/var/www/html/public/covers">
#         Require all granted
#     </Directory>
#     ProxyPreserveHost On
#     RequestHeader set X-Forwarded-Proto "https"
#     ProxyPass /roms/ !
#     ProxyPass /covers/ !
#     ProxyPass / http://127.0.0.1:3000/
#     ProxyPassReverse / http://127.0.0.1:3000/
# </VirtualHost>
