# BBSEngine Handbook - mod_wsgi Configuration
# For serving markdown with runtime conversion via Python/Flask
#
# Installation:
# 1. Install Apache mod_wsgi: sudo apt-get install libapache2-mod-wsgi-py3
# 2. Enable mod_wsgi: sudo a2enmod wsgi
# 3. Copy this file to /etc/apache2/sites-available/
# 4. Enable: sudo a2ensite handbook-wsgi.conf
# 5. Restart: sudo systemctl restart apache2

WSGIDaemonProcess handbook user=www-data group=www-data threads=5 processes=2
WSGIScriptAlias /handbook /home/opencode/data/work/bbsengine6/handbook/wsgi.py

<Directory /home/opencode/data/work/bbsengine6/handbook>
    WSGIProcessGroup handbook
    WSGIApplicationGroup %{GLOBAL}
    Require all granted

    # Security headers
    <IfModule mod_headers.c>
        Header set X-Content-Type-Options "nosniff"
        Header set X-Frame-Options "SAMEORIGIN"
        Header set X-XSS-Protection "1; mode=block"
        Header set Referrer-Policy "strict-origin-when-cross-origin"
    </IfModule>

    # Caching
    <IfModule mod_expires.c>
        ExpiresActive On
        ExpiresDefault "access plus 1 hour"
    </IfModule>

    # Compression
    <IfModule mod_deflate.c>
        AddOutputFilterByType DEFLATE text/html text/plain text/xml application/json text/javascript
    </IfModule>
</Directory>

# Serve static files (CSS, images, etc.) directly from filesystem
<IfModule mod_alias.c>
    AliasMatch ^/handbook/(.*\.(?:css|js|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot))$ \
        /home/opencode/data/work/bbsengine6/handbook/static/$1
</IfModule>

# If using static directory
<Directory /home/opencode/data/work/bbsengine6/handbook/static>
    Require all granted
    <IfModule mod_expires.c>
        ExpiresActive On
        ExpiresByType image/* "access plus 1 month"
        ExpiresByType font/* "access plus 1 month"
        ExpiresByType text/css "access plus 1 week"
        ExpiresByType application/javascript "access plus 1 week"
    </IfModule>
</Directory>

# Logging
ErrorLog ${APACHE_LOG_DIR}/handbook-error.log
CustomLog ${APACHE_LOG_DIR}/handbook-access.log combined
