# GeoSus Admin Panel - Apache Virtual Host
# 
# Required modules:
#   sudo a2enmod proxy proxy_http proxy_wstunnel rewrite headers ssl
#
# Installation:
#   1. sudo cp apache-vhost.conf /etc/apache2/sites-available/geosus.conf
#   2. sudo a2ensite geosus && sudo systemctl reload apache2
#   3. sudo certbot --apache -d geosus.honzuvkod.dev

<VirtualHost *:80>
    ServerName geosus.honzuvkod.dev
    
    ErrorLog ${APACHE_LOG_DIR}/geosus_error.log
    CustomLog ${APACHE_LOG_DIR}/geosus_access.log combined
    
    ProxyPreserveHost On
    ProxyRequests Off
    
    RewriteEngine On
    RewriteCond %{HTTP:Upgrade} websocket [NC]
    RewriteCond %{HTTP:Connection} upgrade [NC]
    RewriteRule ^/admin/ws/(.*)$ ws://127.0.0.1:8088/admin/ws/$1 [P,L]
    
    ProxyPass /admin http://127.0.0.1:8088/admin
    ProxyPassReverse /admin http://127.0.0.1:8088/admin
    
    ProxyPass /api http://127.0.0.1:8088/api
    ProxyPassReverse /api http://127.0.0.1:8088/api
    
    ProxyPass /health http://127.0.0.1:8088/health
    ProxyPassReverse /health http://127.0.0.1:8088/health
    
    Header always set X-Content-Type-Options "nosniff"
    Header always set X-Frame-Options "SAMEORIGIN"
    Header always set X-XSS-Protection "1; mode=block"
    Header always set Referrer-Policy "strict-origin-when-cross-origin"
    
    ProxyTimeout 3600
    SetEnv proxy-nokeepalive 0
    SetEnv proxy-initial-not-pooled 1
</VirtualHost>
