<VirtualHost *:80>
    ServerName localhost
    DocumentRoot /var/www/sabredav
    
    <Directory /var/www/sabredav>
        AllowOverride All
        Require all granted
        Options -Indexes +FollowSymLinks
    </Directory>
    
    # Rewrite rules for CalDAV
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ server.php [QSA,L]
    
    # Well-known CalDAV discovery
    RewriteRule ^\.well-known/caldav / [R=301,L]
    
    # Write errors to stderr for Docker logs
    ErrorLog /proc/self/fd/2
    # CustomLog /proc/self/fd/1 combined
</VirtualHost>
