# Donna Portal — HTTP only on :80
# El Caddy upstream hace terminación SSL y nos pasa X-Forwarded-Proto: https.

:80 {
    root * /opt/donna/public

    encode gzip zstd

    # Bloquear acceso directo a vistas privadas, código fuente, secretos, SQL, etc.
    @hidden {
        path /src/* /sql/* /bin/* /views/* /.env* /.git*
    }
    respond @hidden 404

    # Rewrite /foo → /foo.php cuando el .php existe (para URLs sin extensión: /auth/callback)
    @extlessphp {
        not path *.php
        not path */
        file {path}.php
    }
    rewrite @extlessphp {path}.php

    php_fastcgi unix//run/php/php8.4-fpm.sock {
        env HTTPS on
    }

    file_server {
        index index.php
    }

    log {
        output file /var/log/donna/access.log {
            roll_size 50mb
            roll_keep 5
        }
        format json
    }
}
