server {
    listen 80;
    index index.php index.html;
    server_name _;

    root /var/www/public;

    # Increase upload limit (example: 20 MB)
    client_max_body_size 100M;

    # Handle Laravel routes (pretty URLs, Inertia, Vue)
    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    # Serve storage files (Laravel storage:link)
    location /storage/ {
        alias /var/www/storage/app/public/;
        access_log off;
        expires max;
    }

    # PHP-FPM handling
    location ~ \.php$ {
        include fastcgi_params;
        fastcgi_pass app:9000;   # "app" service from docker-compose
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        fastcgi_param DOCUMENT_ROOT $realpath_root;
        fastcgi_buffers 16 16k;
        fastcgi_buffer_size 32k;
    }

    # Deny access to hidden files & sensitive dirs
    location ~ /\.(?!well-known).* {
        deny all;
    }
}
