<VirtualHost *:80>
    DocumentRoot /var/www/html/public
    DirectoryIndex index.php

    # mod_php does not hand the Authorization header to PHP: without this line every
    # `Authorization: Bearer <token>` is dropped and the API answers "JWT Token not found".
    SetEnvIf Authorization "(.+)" HTTP_AUTHORIZATION=$1

    <Directory /var/www/html/public>
        AllowOverride All
        Require all granted
        FallbackResource /index.php
    </Directory>

    # Disable .htaccess and other sensitive files
    <FilesMatch "^\.">
        Require all denied
    </FilesMatch>

    # Disable access to composer files
    <FilesMatch "(composer\.(json|lock))">
        Require all denied
    </FilesMatch>

    # Optional: Disable access to symfony config files in production
    <Directory /var/www/html/config>
        Require all denied
    </Directory>

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