server {
    listen 80;
    listen [::]:80;
    server_name localhost;
    root /var/www/public;

    index index.html index.php;

    charset utf-8;

    # Subidas grandes (biblioteca de imágenes en lotes, adjuntos de actas).
    client_max_body_size 128M;

    # Rutas de API, sanctum y setup → Laravel
    location ~ ^/(api|sanctum|setup)(/.*)?$ {
        try_files $uri $uri/ /index.php?$query_string;
    }

    # Storage: servir archivo si existe, si no pasar a Laravel
    location ~ ^/storage(/.*)?$ {
        try_files $uri /index.php?$query_string;
    }

    # Todo lo demás → Vue SPA (index.html)
    location / {
        try_files $uri $uri/ /index.html;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    location ~ \.php$ {
        fastcgi_pass prueba2_app:9000;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        include fastcgi_params;
    }

    location ~* \.(jpg|jpeg|png|gif|ico|css|js|woff2?|ttf|svg)$ {
        expires 1d;
        add_header Cache-Control "public, no-transform";
    }

    location ~ /\.(?!well-known).* {
        deny all;
    }
}
