<VirtualHost *:80>
    ServerName homelog.schabetsberger.info
    ServerAdmin webmaster@schabetsberger.info
    
    DocumentRoot /var/www/logbook/backend/public
    
    <Directory /var/www/logbook/backend/public>
        Options -Indexes +FollowSymLinks
        AllowOverride All
        Require all granted
        
        # Rewrite for API Routes
        <IfModule mod_rewrite.c>
            RewriteEngine On
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteRule ^ index.php [QSA,L]
        </IfModule>
    </Directory>
    
    # Logs
    ErrorLog ${APACHE_LOG_DIR}/logbook-error.log
    CustomLog ${APACHE_LOG_DIR}/logbook-access.log combined
    
    # PHP Settings
    <FilesMatch \.php$>
        SetHandler "proxy:unix:/var/run/php/php8.1-fpm.sock|fcgi://localhost"
    </FilesMatch>
    
    # Security Headers
    Header always set X-Frame-Options "SAMEORIGIN"
    Header always set X-Content-Type-Options "nosniff"
    Header always set X-XSS-Protection "1; mode=block"
    
    # CORS Headers für API
    Header always set Access-Control-Allow-Origin "*"
    Header always set Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS"
    Header always set Access-Control-Allow-Headers "Content-Type, Authorization"
    
    # Upload Size
    php_value upload_max_filesize 5M
    php_value post_max_size 10M
</VirtualHost>

# SSL Configuration (wird von Certbot automatisch hinzugefügt)
# Oder manuell ergänzen wenn bereits SSL-Zertifikat vorhanden
